Skip to content

Give the validate_files tests an unowned file that exists - #150

Merged
dduugg merged 1 commit into
mainfrom
fix-validate-files-test-fixture
Nov 12, 2026
Merged

dduugg merged 1 commit into
mainfrom
fix-validate-files-test-fixture

Conversation

@dduugg

@dduugg dduugg commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Three tests in tests/validate_files_test.rs named valid_project/ruby/app/unowned.rb, which doesn't exist. valid_project has to validate cleanly, so it has no unowned file. The tests passed only because a path that doesn't exist is reported as unowned, so they covered that case rather than an unowned file.

Found by @perryqh in #126.

Why

The tests didn't test what their names say. They would also have started failing if nonexistent paths were ever skipped, as #126 proposed.

Changes

  • A new valid_project_with_unowned_file helper copies valid_project to a temp dir, writes ruby/app/unowned.rb there, and stages it.
  • test_validate_with_unowned_file, test_validate_with_mixed_files and test_generate_and_validate_with_unowned_file use it.
  • Each test now checks the whole output (Unowned files detected:\n ruby/app/unowned.rb\n), so the mixed test also checks that ruby/app/models/payroll.rb isn't reported.

#126 pointed these tests at invalid_project instead. That fixture's CODEOWNERS is empty, so every file there is reported as unowned, and the mixed test couldn't tell an owned file from an unowned one.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings and cargo test pass (306 passed, the 3 existing ignores).
  • Mutation check: with validate_files temporarily changed to skip nonexistent paths, the three old tests fail and the new ones pass.

Three tests in validate_files_test.rs named valid_project's
ruby/app/unowned.rb, which doesn't exist: valid_project has to
validate cleanly, so it has no unowned file. They passed only because
a path that doesn't exist is reported as unowned, so they covered that
rather than an unowned file, and would have started failing if
nonexistent paths were ever skipped, as #126 proposed.

They now write ruby/app/unowned.rb into a temp copy of valid_project
and stage it. The invalid_project fixture, which #126 pointed them at,
has an empty CODEOWNERS, so every file there is reported as unowned
and the mixed test couldn't tell an owned file from an unowned one.

Each test now checks the whole output, so the mixed test also checks
that ruby/app/models/payroll.rb isn't reported.
@dduugg
dduugg requested a review from a team as a code owner November 12, 2026 23:48
@github-project-automation github-project-automation Bot moved this to Triage in Modularity Nov 12, 2026
@dduugg
dduugg merged commit 7105a6f into main Nov 12, 2026
13 checks passed
@dduugg
dduugg deleted the fix-validate-files-test-fixture branch November 12, 2026 23:53
@github-project-automation github-project-automation Bot moved this from Triage to Done in Modularity Nov 12, 2026
@dduugg dduugg mentioned this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant