Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def _has_paired_test_file(rel_path: str, path_basenames: set[str]) -> bool:
candidates = {
f"test_{stem}.py",
f"{stem}_test{test_suffix}",
f"{stem}_spec{test_suffix}",
f"{stem}.test.ts",
f"{stem}.test.tsx",
f"{stem}.test.js",
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/health/test_paired_test_basenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def _reference_has_paired_test_file(rel_path: str, all_paths: set[str]) -> bool:
candidates = {
f"test_{stem}.py",
f"{stem}_test.py",
f"{stem}_spec.rb",
f"{stem}.test.ts",
f"{stem}.test.tsx",
f"{stem}.test.js",
Expand Down Expand Up @@ -102,3 +103,12 @@ def test_basenames_split_on_forward_slash_only(self) -> None:
def test_empty_paths(self) -> None:
assert _path_basenames(set()) == set()
assert not _has_paired_test_file("anything.py", set())

def test_ruby_and_crystal_underscore_spec_pairing(self) -> None:
"""Ruby's <stem>_spec.rb (and Crystal's <stem>_spec.cr) is a paired test (#1768)."""
ruby = {"spec/user_spec.rb"}
assert _has_paired_test_file("lib/user.rb", _path_basenames(ruby))
crystal = {"spec/user_spec.cr"}
assert _has_paired_test_file("src/user.cr", _path_basenames(crystal))
# Same stem, dot form, must NOT count for Ruby's underscore layout.
assert not _has_paired_test_file("lib/user.rb", _path_basenames({"spec/user.spec.rb"}))
2 changes: 2 additions & 0 deletions tests/unit/server/mcp/test_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ def test_classify_bus_factor_unknown_team_size_keeps_behaviour():
("lib/user.dart", "test/user_test.dart"),
("lib/user.ex", "test/user_test.exs"),
("src/user.rs", "tests/user_test.rs"),
("lib/user.rb", "spec/user_spec.rb"),
("src/user.cr", "spec/user_spec.cr"),
],
)
def test_health_filename_heuristic_supports_suffix_test_conventions(source, test):
Expand Down
Loading