Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coveragerc: support for relative paths to config (not cwd) #914

Open
blueyed opened this issue Jan 6, 2020 · 1 comment
Open

coveragerc: support for relative paths to config (not cwd) #914

blueyed opened this issue Jan 6, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@blueyed
Copy link
Contributor

blueyed commented Jan 6, 2020

It would be helpful for when coverage gets run in a changed cwd with subprocess handling:

983004.64c4: cwd is now '…/Vcs/pytest-django'
983004.64c4: Tracing '…/Vcs/pytest-django/pytest_django/lazy_django.py'
983023.734b: cwd is now '/tmp/pytest-of-user/pytest-370/test_django_assert_num_queries_output_info0'
983023.734b: Not tracing '…/Vcs/pytest-django/pytest_django/lazy_django.py': falls outside the --include trees

Currently you have to set an environment variable, e.g.

tox.ini:

setenv =
    coverage: COVERAGE_HOME={toxinidir}

coverage.rc:

[run]
source =
  $COVERAGE_HOME/src
  $COVERAGE_HOME/tests

Since this should be working in a backward compatible way, I suggest either
supporting a ./ prefix to enable it, or set some environment variable like
$COVERAGE_CONFIG_DIR before reading the config file.

With the first approach source = . would use the current working directory, but source = ./ would use the directory of the config file.

(via #597 (comment))

Link to current docs, which say that it is relative to cwd: https://coverage.readthedocs.io/en/latest/source.html#execution

@blueyed blueyed added the enhancement New feature or request label Jan 6, 2020
@omry
Copy link

omry commented Mar 1, 2020

I am also running into issues cases by me needing to run coverage in a different directory.
another more explicit approach to ./ prefix is to have COVERAGE_HOME set automatically by coverage when it loads the config.

This way something like the config below would work regardless of the presence of the environment variable.

[run]
omit = 
    ${COVERAGE_HOME}/.nox/*
    ${COVERAGE_HOME}/*tests*
    ${COVERAGE_HOME}/plugins/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants