Skip to content

Commit 084bafe

Browse files
committed
coverage: move config from .coveragerc to pyproject.toml
Getting rid of another top-level file. `coverage.py` has supported `pyproject.toml` since version 5.0, and all versions of coverage so far work with python 2.7. We just need to ensure that a version of coverage with the `toml` extra is installed in the test environment. I tested this with `coverage run`, `coverage report`, and `coverage html`.
1 parent 775c822 commit 084bafe

File tree

3 files changed

+67
-69
lines changed

3 files changed

+67
-69
lines changed

.coveragerc

-38
This file was deleted.

.github/workflows/unit_tests.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
sudo apt-get -y install zlib1g-dev libdw-dev libiberty-dev
138138
- name: Install Python packages
139139
run: |
140-
pip install --upgrade pip six setuptools codecov coverage
140+
pip install --upgrade pip six setuptools codecov coverage[toml]
141141
- name: Setup git configuration
142142
run: |
143143
# Need this for the git tests to succeed.
@@ -205,7 +205,7 @@ jobs:
205205
sudo apt-get -y install zlib1g-dev libdw-dev libiberty-dev
206206
- name: Install Python packages
207207
run: |
208-
pip install --upgrade pip six setuptools codecov coverage
208+
pip install --upgrade pip six setuptools codecov coverage[toml]
209209
- name: Setup git configuration
210210
run: |
211211
# Need this for the git tests to succeed.
@@ -326,7 +326,7 @@ jobs:
326326
make -C ${KCOV_ROOT}/build && sudo make -C ${KCOV_ROOT}/build install
327327
- name: Install Python packages
328328
run: |
329-
pip install --upgrade pip six setuptools codecov coverage clingo
329+
pip install --upgrade pip six setuptools codecov coverage[toml] clingo
330330
- name: Setup git configuration
331331
run: |
332332
# Need this for the git tests to succeed.
@@ -369,7 +369,7 @@ jobs:
369369
- name: Install Python packages
370370
run: |
371371
pip install --upgrade pip six setuptools
372-
pip install --upgrade codecov coverage
372+
pip install --upgrade codecov coverage[toml]
373373
pip install --upgrade flake8 isort>=4.3.5 mypy>=0.900
374374
- name: Setup Homebrew packages
375375
run: |

pyproject.toml

+63-27
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,69 @@ namespace_packages = true
2626
ignore_errors = true
2727
ignore_missing_imports = true
2828

29-
[[tool.mypy.overrides]]
30-
module = 'spack.*'
31-
ignore_errors = false
32-
ignore_missing_imports = false
33-
34-
[[tool.mypy.overrides]]
35-
module = 'packages.*'
36-
ignore_errors = false
37-
ignore_missing_imports = false
38-
39-
[[tool.mypy.overrides]]
40-
module = 'llnl.*'
41-
ignore_errors = false
42-
ignore_missing_imports = false
43-
44-
[[tool.mypy.overrides]]
45-
module = 'spack.test.packages'
46-
ignore_errors = true
29+
[[tool.mypy.overrides]]
30+
module = 'spack.*'
31+
ignore_errors = false
32+
ignore_missing_imports = false
33+
34+
[[tool.mypy.overrides]]
35+
module = 'packages.*'
36+
ignore_errors = false
37+
ignore_missing_imports = false
38+
39+
[[tool.mypy.overrides]]
40+
module = 'llnl.*'
41+
ignore_errors = false
42+
ignore_missing_imports = false
43+
44+
[[tool.mypy.overrides]]
45+
module = 'spack.test.packages'
46+
ignore_errors = true
4747

48-
# ignore errors in fake import path for packages
49-
[[tool.mypy.overrides]]
50-
module = 'spack.pkg.*'
48+
# ignore errors in fake import path for packages
49+
[[tool.mypy.overrides]]
50+
module = 'spack.pkg.*'
51+
ignore_errors = true
52+
ignore_missing_imports = true
53+
54+
# jinja has syntax in it that requires python3 and causes a parse error
55+
# skip importing it
56+
[[tool.mypy.overrides]]
57+
module = 'jinja2'
58+
follow_imports = 'skip'
59+
60+
[tool.coverage.run]
61+
parallel = true
62+
concurrency = ["multiprocessing"]
63+
branch = true
64+
source = ["bin", "lib"]
65+
omit = [
66+
'lib/spack/spack/test/*',
67+
'lib/spack/docs/*',
68+
'lib/spack/external/*',
69+
'share/spack/qa/*',
70+
]
71+
72+
[tool.coverage.report]
73+
# Regexes for lines to exclude from consideration
74+
exclude_lines = [
75+
# Have to re-enable the standard pragma
76+
'pragma: no cover',
77+
78+
# Don't complain about missing debug-only code:
79+
'def __repr__',
80+
'if self\.debug',
81+
82+
# Don't complain if tests don't hit defensive assertion code:
83+
'raise AssertionError',
84+
'raise NotImplementedError',
85+
86+
# Don't complain if non-runnable code isn't run:
87+
'if 0:',
88+
'if False:',
89+
'if __name__ == .__main__.:',
90+
]
5191
ignore_errors = true
52-
ignore_missing_imports = true
5392

54-
# jinja has syntax in it that requires python3 and causes a parse error
55-
# skip importing it
56-
[[tool.mypy.overrides]]
57-
module = 'jinja2'
58-
follow_imports = 'skip'
93+
[tool.coverage.html]
94+
directory = "htmlcov"

0 commit comments

Comments
 (0)