Skip to content

fix: ensure tests never access ~/.km directory#1104

Merged
dluc merged 1 commit intomainfrom
testisolation
Dec 2, 2025
Merged

fix: ensure tests never access ~/.km directory#1104
dluc merged 1 commit intomainfrom
testisolation

Conversation

@dluc
Copy link
Collaborator

@dluc dluc commented Dec 2, 2025

Summary

  • Tests now create isolated temporary directories instead of using ~/.km
  • Enforces proper test isolation as required by docs/AGENTS.md
  • Prevents tests from touching user data

Changes

  • tests/Main.Tests/Unit/CLI/CliApplicationBuilderTests.cs:

    • Implemented IDisposable for proper cleanup
    • Uses temp directory with unique GUID for each test
    • Passes --config <temp_path> to avoid ~/.km access
  • tests/Main.Tests/Integration/ExamplesCommandOutputTest.cs:

    • Creates isolated temp directory for config file
    • Cleans up temp directory in finally block

Test plan

  • All 520 tests pass (306 Core + 214 Main)
  • Zero skipped tests
  • Code coverage at 83.82% (above 80% threshold)
  • build.sh passes with 0 warnings
  • format.sh passes
  • coverage.sh passes
  • Tests no longer access ~/.km directory

Compliance

Per docs/AGENTS.md:

"Tests must never read or write files at ~/.km/ - Tests must use temp dirs"

Tests now create isolated temporary directories instead of using the
user's personal ~/.km directory. This enforces proper test isolation
and prevents tests from touching user data.

Changes:
- CliApplicationBuilderTests: use temp config path, implement IDisposable
- ExamplesCommandOutputTest: use isolated temp directory for config
@dluc dluc merged commit 58c9e47 into main Dec 2, 2025
7 checks passed
@dluc dluc deleted the testisolation branch December 2, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant