summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-08-09 08:30:15 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-08-09 08:30:15 -0400
commit15945f2408efaf164a3a78f67ef74a74d557fa82 (patch)
tree527c852b96d3911393e12e8a4dbd716bb1204437
parent5a4f125853b5056f98d80162687b6d1eace38ea1 (diff)
downloadpython-coveragepy-git-15945f2408efaf164a3a78f67ef74a74d557fa82.tar.gz
test: show contexts in metacov report
-rw-r--r--.github/workflows/coverage.yml12
-rw-r--r--igor.py5
-rw-r--r--metacov.ini6
3 files changed, 10 insertions, 13 deletions
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index f8aca5cb..7b61deda 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -70,22 +70,13 @@ jobs:
- name: "Run tox coverage for ${{ matrix.python-version }}"
env:
COVERAGE_COVERAGE: "yes"
+ COVERAGE_CONTEXT: "${{ matrix.python-version }}.${{ matrix.os }}"
run: |
set -xe
# Something about pytest 6.x with xdist keeps data from collecting.
# Use -n0 for now.
python -m tox -- -n 0
- - name: "Combine"
- env:
- COVERAGE_COVERAGE: "yes"
- COVERAGE_RCFILE: "metacov.ini"
- COVERAGE_METAFILE: ".metacov"
- run: |
- set -xe
- COVERAGE_DEBUG=dataio python -m igor combine_html
- mv .metacov .metacov.${{ matrix.python-version }}.${{ matrix.os }}
-
- name: "Upload coverage data"
uses: actions/upload-artifact@v2
with:
@@ -126,6 +117,7 @@ jobs:
env:
COVERAGE_RCFILE: "metacov.ini"
COVERAGE_METAFILE: ".metacov"
+ COVERAGE_CONTEXT: "yes"
run: |
set -xe
python -m igor combine_html
diff --git a/igor.py b/igor.py
index e6b3c313..0ea93e40 100644
--- a/igor.py
+++ b/igor.py
@@ -135,6 +135,9 @@ def run_tests_with_coverage(tracer, *runner_args):
os.environ['COVERAGE_TESTING'] = "True"
os.environ['COVERAGE_PROCESS_START'] = os.path.abspath('metacov.ini')
os.environ['COVERAGE_HOME'] = os.getcwd()
+ context = os.environ.get('COVERAGE_CONTEXT')
+ if context:
+ os.environ['COVERAGE_CONTEXT'] = context + "." + tracer
# Create the .pth file that will let us measure coverage in sub-processes.
# The .pth file seems to have to be alphabetically after easy-install.pth
@@ -192,7 +195,7 @@ def do_combine_html():
cov.load()
cov.combine()
cov.save()
- show_contexts = bool(os.environ.get('COVERAGE_CONTEXT'))
+ show_contexts = bool(os.environ.get('COVERAGE_DYNCTX') or os.environ.get('COVERAGE_CONTEXT'))
cov.html_report(show_contexts=show_contexts)
cov.xml_report()
diff --git a/metacov.ini b/metacov.ini
index 9dab77aa..209c1212 100644
--- a/metacov.ini
+++ b/metacov.ini
@@ -13,8 +13,10 @@ parallel = true
source =
${COVERAGE_HOME-.}/coverage
${COVERAGE_HOME-.}/tests
-# $set_env.py: COVERAGE_CONTEXT - Set to 'test_function' for who-tests-what
-dynamic_context = ${COVERAGE_CONTEXT-none}
+# $set_env.py: COVERAGE_DYNCTX - Set to 'test_function' for who-tests-what
+dynamic_context = ${COVERAGE_DYNCTX-none}
+# $set_env.py: COVERAGE_CONTEXT - Set to a static context for this run
+context = ${COVERAGE_CONTEXT-none}
[report]
# We set a different pragmas so our code won't be confused with test code, and