Skip to content

Commit 5370daa

Browse files
authored
Merge pull request #1043 from LalatenduMohanty/add-combined-coverage-scripts
feat(test): add hatch scripts and docs for coverage reports
2 parents c5c3afc + 7c49d1e commit 5370daa

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ htmlcov/
4545
.cache
4646
nosetests.xml
4747
coverage.xml
48+
coverage-report-*.md
4849
*.cover
4950
*.py.cover
5051
.hypothesis/

docs/develop.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,26 @@ recent version of Python (as defined in `pyproject.toml` under `project.requires
3939
- `hatch run test:test` - Run unit tests with coverage
4040
- `hatch run test:test tests/test_bootstrapper.py` - Run specific test files
4141
- `hatch run test:test -k "test_metadata"` - Run tests with custom args
42-
- `hatch run test:coverage-report` - Generate coverage report
42+
- `hatch run test:coverage-erase` - Clean old coverage data
43+
- `hatch run test:coverage-report` - Combine and generate markdown coverage report (saved to `coverage-report-<timestamp>.md`)
44+
45+
**Coverage Report:**
46+
47+
To generate a coverage report that includes both unit and e2e tests:
48+
49+
```bash
50+
hatch run test:coverage-erase # Clean old coverage data
51+
hatch run test:test # Run unit tests (collects coverage)
52+
./e2e/run_all.sh # Run all e2e tests (collects coverage)
53+
hatch run test:coverage-report # Combine and generate markdown report
54+
```
55+
56+
The report is printed to the terminal and saved to a timestamped file
57+
(`coverage-report-YYYYMMDD-HHMMSS.md`). For unit-test-only coverage,
58+
skip the `run_all.sh` step. To run a single e2e suite instead of all,
59+
replace `run_all.sh` with one of: `ci_bootstrap_suite.sh`,
60+
`ci_bootstrap_parallel_suite.sh`, `ci_build_suite.sh`, `ci_config_suite.sh`,
61+
`ci_specialized_suite.sh`, `ci_workflow_suite.sh`.
4362

4463
**Linting & Code Quality:**
4564

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ features = ["test"]
229229

230230
[tool.hatch.envs.test.scripts]
231231
test = "python -m coverage run -m pytest --log-level DEBUG -vv {args:tests}"
232-
coverage-report = ["coverage combine", "coverage report --format=markdown"]
232+
coverage-erase = "coverage erase"
233+
coverage-combine = "coverage combine"
234+
coverage-report = ["coverage combine", "coverage report --format=markdown | tee coverage-report-$(date +%Y%m%d-%H%M%S).md"]
233235

234236
[tool.hatch.envs.lint]
235237
description = "Run linters."

0 commit comments

Comments
 (0)