Skip to content

[BUG-P2] test_auto_scans_on_fresh_workspace fails intermittently — clean_app fixture .codelens not gitignored #83

Description

@Wolfvin

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

  1. benchmarks/fixtures/clean_app/ is a fixture directory used by multiple tests.
  2. 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).
  3. 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).
  4. 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

  • test_auto_scans_on_fresh_workspace passes even after test_vuln_staleness.py has run in the same suite
  • benchmarks/fixtures/*/.codelens/ is gitignored (no fixture-created .codelens dirs tracked)
  • No .codelens dirs in any benchmarks/fixtures/ path committed to the repo

Files

  • .gitignore (Option A)
  • tests/test_architecture.py (Option B — fresh_clean_app fixture)
  • Possibly other test files that copy fixture directories

Related

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions