Summary
tests/test_architecture.py::TestArchitectureBasic::test_auto_scans_on_fresh_workspace fails intermittently because benchmarks/fixtures/clean_app/.codelens/ is not gitignored. Tests that scan the clean_app fixture (e.g., test_vuln_staleness.py) create .codelens/osv_cache.db inside the fixture directory, which then pollutes the fresh_clean_app copy used by the architecture test.
Root cause
benchmarks/fixtures/clean_app/ is a fixture directory used by multiple tests.
- Tests like
test_vuln_staleness.py run vuln-scan on clean_app, which creates .codelens/osv_cache.db inside the fixture directory (not a temp copy).
test_auto_scans_on_fresh_workspace copies clean_app to a temp dir and asserts .codelens does NOT exist in the copy (because it's supposed to be a "fresh" workspace).
- The copy includes
.codelens (because it's now on disk), so the assertion fails.
Evidence
# Run test in isolation — still fails because .codelens is already on disk
PYTHONPATH=scripts python3 -m pytest tests/test_architecture.py::TestArchitectureBasic::test_auto_scans_on_fresh_workspace -v
# FAILED
# Check fixture directory
ls benchmarks/fixtures/clean_app/.codelens/
# osv_cache.db ← created by previous test run, not gitignored
# Clean up
rm -rf benchmarks/fixtures/clean_app/.codelens
# Re-run test — passes
PYTHONPATH=scripts python3 -m pytest tests/test_architecture.py::TestArchitectureBasic::test_auto_scans_on_fresh_workspace -v
# PASSED
Impact
- Intermittent CI failure:
test_auto_scans_on_fresh_workspace fails whenever a prior test in the same suite has scanned clean_app and left .codelens behind. In CI, test order is deterministic so this may fail consistently.
- False alarm for contributors: a contributor running the full test suite sees 1 failure that has nothing to do with their changes.
- Not a regression: this is pre-existing. Verified by running the test in isolation (still fails) and cleaning up the fixture (passes).
Fix
Two options:
Option A (recommended): gitignore .codelens in fixture directories
Add to .gitignore:
benchmarks/fixtures/*/.codelens/
This prevents .codelens from being tracked, but doesn't prevent tests from creating it on disk. The architecture test would still fail if .codelens exists on disk.
Option B (better): fix the fresh_clean_app fixture to exclude .codelens when copying
In tests/test_architecture.py, the fixture that creates fresh_clean_app should use shutil.copytree with ignore=shutil.ignore_patterns('.codelens'):
fresh_clean_app = tempfile.mkdtemp()
shutil.copytree(
clean_app_source,
fresh_clean_app,
dirs_exist_ok=True,
ignore=shutil.ignore_patterns('.codelens', '__pycache__'),
)
This makes the test robust regardless of what other tests leave behind in the fixture directory.
Option C (belt-and-suspenders): both A + B
Gitignore the .codelens dirs (so they don't get committed) AND fix the fixture to exclude them when copying (so test order doesn't matter).
Acceptance criteria
Files
.gitignore (Option A)
tests/test_architecture.py (Option B — fresh_clean_app fixture)
- Possibly other test files that copy fixture directories
Related
Summary
tests/test_architecture.py::TestArchitectureBasic::test_auto_scans_on_fresh_workspacefails intermittently becausebenchmarks/fixtures/clean_app/.codelens/is not gitignored. Tests that scan theclean_appfixture (e.g.,test_vuln_staleness.py) create.codelens/osv_cache.dbinside the fixture directory, which then pollutes thefresh_clean_appcopy used by the architecture test.Root cause
benchmarks/fixtures/clean_app/is a fixture directory used by multiple tests.test_vuln_staleness.pyrunvuln-scanonclean_app, which creates.codelens/osv_cache.dbinside the fixture directory (not a temp copy).test_auto_scans_on_fresh_workspacecopiesclean_appto a temp dir and asserts.codelensdoes NOT exist in the copy (because it's supposed to be a "fresh" workspace)..codelens(because it's now on disk), so the assertion fails.Evidence
Impact
test_auto_scans_on_fresh_workspacefails whenever a prior test in the same suite has scannedclean_appand left.codelensbehind. In CI, test order is deterministic so this may fail consistently.Fix
Two options:
Option A (recommended): gitignore
.codelensin fixture directoriesAdd to
.gitignore:This prevents
.codelensfrom being tracked, but doesn't prevent tests from creating it on disk. The architecture test would still fail if.codelensexists on disk.Option B (better): fix the
fresh_clean_appfixture to exclude.codelenswhen copyingIn
tests/test_architecture.py, the fixture that createsfresh_clean_appshould useshutil.copytreewithignore=shutil.ignore_patterns('.codelens'):This makes the test robust regardless of what other tests leave behind in the fixture directory.
Option C (belt-and-suspenders): both A + B
Gitignore the
.codelensdirs (so they don't get committed) AND fix the fixture to exclude them when copying (so test order doesn't matter).Acceptance criteria
test_auto_scans_on_fresh_workspacepasses even aftertest_vuln_staleness.pyhas run in the same suitebenchmarks/fixtures/*/.codelens/is gitignored (no fixture-created.codelensdirs tracked).codelensdirs in anybenchmarks/fixtures/path committed to the repoFiles
.gitignore(Option A)tests/test_architecture.py(Option B —fresh_clean_appfixture)Related
test_compact_format.pyand other tests that useclean_appfixture may have the same issue