Skip to content

7.0.0 _glob_to_regex fails in directories with regexp characters #1513

Closed
@ktlim

Description

@ktlim

Describe the bug
We build and test in directories that contain the + character (as a separator in a version string). Using a .coveragerc file in such a directory that contains an omit specification that does not begin with a * or ? wildcard fails.

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using?
    3.10
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
    7.0.0. 6.5.0 is fine.
-- sys -------------------------------------------------------
               coverage_version: 7.0.0
                coverage_module: /sdf/home/k/ktl/.conda/envs/covtest/lib/python3.10/site-packages/coverage/__init__.py
                         tracer: -none-
                        CTracer: available
           plugins.file_tracers: -none-
            plugins.configurers: -none-
      plugins.context_switchers: -none-
              configs_attempted: .coveragerc
                                 setup.cfg
                                 tox.ini
                                 pyproject.toml
                   configs_read: -none-
                    config_file: None
                config_contents: -none-
                      data_file: -none-
                         python: 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:23:14) [GCC 10.4.0]
                       platform: Linux-4.18.0-372.32.1.el8_6.x86_64-x86_64-with-glibc2.28
                 implementation: CPython
                     executable: /sdf/home/k/ktl/.conda/envs/covtest/bin/python
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 2829394
                            cwd: /sdf/home/k/ktl
                           path: /sdf/home/k/ktl/.conda/envs/covtest/bin
                                 /sdf/home/k/ktl/.conda/envs/covtest/eups/python
                                 /sdf/home/k/ktl/.conda/envs/covtest/lib/python310.zip
                                 /sdf/home/k/ktl/.conda/envs/covtest/lib/python3.10
                                 /sdf/home/k/ktl/.conda/envs/covtest/lib/python3.10/lib-dynload
                                 /sdf/home/k/ktl/.conda/envs/covtest/lib/python3.10/site-packages
                    environment: CONDA_PYTHONBREAKPOINT =
                                 CONDA_PYTHON_EXE = /sdf/group/rubin/sw/conda/bin/python
                                 HOME = /sdf/home/k/ktl
                                 OBJCOPY = /sdf/home/k/ktl/.conda/envs/covtest/bin/x86_64-conda-linux-gnu-objcopy
                                 PYTHONPATH = /sdf/home/k/ktl/.conda/envs/covtest/eups/python
                                 _CONDA_PYTHON_SYSCONFIGDATA_NAME = _sysconfigdata_x86_64_conda_cos6_linux_gnu
                   command_line: /sdf/home/k/ktl/.conda/envs/covtest/bin/coverage debug sys
         sqlite3_sqlite_version: 3.40.0
             sqlite3_temp_store: 0
        sqlite3_compile_options: ATOMIC_INTRINSICS=1, COMPILER=gcc-10.4.0, DEFAULT_AUTOVACUUM,
                                 DEFAULT_CACHE_SIZE=-2000, DEFAULT_FILE_FORMAT=4,
                                 DEFAULT_JOURNAL_SIZE_LIMIT=-1, DEFAULT_MMAP_SIZE=0, DEFAULT_PAGE_SIZE=4096,
                                 DEFAULT_PCACHE_INITSZ=20, DEFAULT_RECURSIVE_TRIGGERS,
                                 DEFAULT_SECTOR_SIZE=4096, DEFAULT_SYNCHRONOUS=2,
                                 DEFAULT_WAL_AUTOCHECKPOINT=1000, DEFAULT_WAL_SYNCHRONOUS=2,
                                 DEFAULT_WORKER_THREADS=0, ENABLE_COLUMN_METADATA, ENABLE_DBSTAT_VTAB,
                                 ENABLE_FTS3, ENABLE_FTS3_TOKENIZER, ENABLE_FTS4, ENABLE_FTS5,
                                 ENABLE_GEOPOLY, ENABLE_MATH_FUNCTIONS, ENABLE_RTREE, ENABLE_UNLOCK_NOTIFY,
                                 MALLOC_SOFT_LIMIT=1024, MAX_ATTACHED=10, MAX_COLUMN=2000,
                                 MAX_COMPOUND_SELECT=500, MAX_DEFAULT_PAGE_SIZE=8192, MAX_EXPR_DEPTH=10000,
                                 MAX_FUNCTION_ARG=127, MAX_LENGTH=1000000000, MAX_LIKE_PATTERN_LENGTH=50000,
                                 MAX_MMAP_SIZE=0x7fff0000, MAX_PAGE_COUNT=1073741823, MAX_PAGE_SIZE=65536,
                                 MAX_SQL_LENGTH=1000000000, MAX_TRIGGER_DEPTH=1000,
                                 MAX_VARIABLE_NUMBER=250000, MAX_VDBE_OP=250000000, MAX_WORKER_THREADS=8,
                                 MUTEX_PTHREADS, SECURE_DELETE, SYSTEM_MALLOC, TEMP_STORE=1, THREADSAFE=1
  1. What versions of what packages do you have installed? The output of pip freeze is helpful.
(covtest) $ conda list
# packages in environment at /sdf/home/k/ktl/.conda/envs/covtest:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.12.7            ha878542_0    conda-forge
coverage                  7.0.0           py311h2582759_0    conda-forge
ld_impl_linux-64          2.39                 hcc3a1bd_1    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 12.2.0              h65d4601_19    conda-forge
libgomp                   12.2.0              h65d4601_19    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libsqlite                 3.40.0               h753d276_0    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.13               h166bdaf_4    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
openssl                   3.0.7                h0b41bf4_1    conda-forge
pip                       22.3.1             pyhd8ed1ab_0    conda-forge
python                    3.11.0          ha86cf86_0_cpython    conda-forge
python_abi                3.11                    3_cp311    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
  1. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.
$ mkdir cov+test cov+test/tests
$ cd cov+test
$ echo -e "[run]\nomit = x/*" > .coveragerc
$ echo -e "def test_foo():\n    assert 4 == 4" > tests/test_foo.py
$ coverage run tests/test_foo.py
File pattern can't include '+'
$ cd ..
$ mv cov+test covtest
$ cd covtest
$ coverage run tests/test_foo.py
$
  1. What commands did you run?
    See above.

Expected behavior
See above.

Additional context
I'm not sure why a complex custom glob-to-regexp translator was used instead of glob, but I suggest that regexp metacharacters be quoted instead of causing failures, as they're quite legal and not infrequently used in pathnames. Perhaps leaving out files.py:328 would be sufficient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions