Enhance testing configuration and coverage measurement#638
Conversation
…and isolated filesystem paths
| def get_test_cpu_count() -> str: | ||
| """Determine how many CPUs to use for pytest-xdist.""" | ||
| return str(cpu_count()) if os.getenv("CI") else "auto" |
There was a problem hiding this comment.
on local this ensures not all cores will be used (3/4th I believe), while on the CI we take all that are available
| [tool.coverage.paths] | ||
| source = ["auto_dev", "/tmp/*/auto_dev"] |
There was a problem hiding this comment.
this increased test coverage locally from ~34% to ~53%
We have some issue on CI generating the coverage report tho, it appears (see CI run)
1s
Run MishaKav/pytest-coverage-comment@main
File read successfully "/Users/runner/work/auto_dev/auto_dev/./coverage-report.txt"
Error: Coverage file "/Users/runner/work/auto_dev/auto_dev/./coverage-report.txt" has bad format or wrong data
./coverage-report.txt
Nothing to report
tests/test_protocol.py
Outdated
| HYPOTHESIS_SETTINGS = """ | ||
| from hypothesis import HealthCheck, settings | ||
|
|
||
| settings.register_profile("generated", deadline=1000, suppress_health_check=[HealthCheck.too_slow]) | ||
| settings.load_profile("generated") | ||
| """ |
There was a problem hiding this comment.
When running with pytest-xdist, certain harmless issues incorrectly surface. To avoid modifying the scaffolded codebase in a way that affects production code, we inject a workaround into the generated tests/__init__.py during integration tests to ensure tests pass without impacting the production scaffold
tests/test_protocol.py
Outdated
| result = subprocess.run(command, env=env, check=False, text=True, capture_output=True) | ||
| result = subprocess.run(command, check=False, text=True, capture_output=True) |
There was a problem hiding this comment.
no longer needed now that monkeypatch.setenv is used in the fixtures
tests/test_repo.py
Outdated
| assert not error_messages | ||
|
|
||
|
|
||
| @pytest.mark.skip |
There was a problem hiding this comment.
These are the ghosts of a flawed pattern I once endorsed. I’ve since repented; see #639
tests/test_repo.py
Outdated
| make_commands = "fmt", "lint", "test" | ||
|
|
||
|
|
||
| @pytest.mark.skip |
There was a problem hiding this comment.
Why skip this entire set of tests?
There was a problem hiding this comment.
This was temporary, since these tests were very poorly written and caused interference with other tests. They have been re-enabled in PR #639, which was already merged into this PR, and this is their current state in this PR:
Lines 1 to 55 in 876757d
Streamline repo scaffolding & re-write & re-enable repo scaffolding tests
PYTHONPATHintest_filesystemfixtures to improve test isolationpytest-xdistsupport inpyproject.tomlfor parallel test executionhypothesis.settingsfor scaffolded protocolspyproject.tomlto include additionaltool.coveragesettings for isolated filesystem pathsget_test_cpu_countinauto_dev/testsbased onos.environ.get('CI')Disabled--> Re-enabled in Streamline repo scaffolding & re-write & re-enable repo scaffolding tests #639test_repo.pytemporarily for stability.Note: PR #639 re-enables
test_repo.py