fix(health): recognize Ruby <stem>_spec.rb test pairing - #1841
Conversation
|
✅ Health of changed files: 3.3 → 3.3 (+0.1) 📋 At a glance Files & modules (2)
✅ Health gate: passed 📌 Before you merge
🔎 More signals (2)🗺️ Change map flowchart LR
subgraph PR ["Changed in this PR (1 with dependents)"]
f_packages_core_src_repowise_core_analysis_health_engine_py[".../health/engine.py 🔥"]:::changed
end
f_packages_cli_src_repowise_cli_commands_update_cmd_command_py[".../update_cmd/command.py"]
f_packages_core_src_repowise_core_analysis_health_engine_py --> f_packages_cli_src_repowise_cli_commands_update_cmd_command_py
f_packages_core_src_repowise_core_analysis_health___init___py[".../health/__init__.py"]
f_packages_core_src_repowise_core_analysis_health_engine_py --> f_packages_core_src_repowise_core_analysis_health___init___py
f_packages_core_src_repowise_core_analysis_health_biomarkers_registry_py[".../biomarkers/registry.py"]
f_packages_core_src_repowise_core_analysis_health_engine_py --> f_packages_core_src_repowise_core_analysis_health_biomarkers_registry_py
f_packages_core_src_repowise_core_analysis_health_complexity_models_py[".../complexity/models.py"]
f_packages_core_src_repowise_core_analysis_health_engine_py --> f_packages_core_src_repowise_core_analysis_health_complexity_models_py
more(["+3 more dependents"])
PR --> more
t_tests_unit_health_test_file_nloc_py(["✅ .../health/test_file_nloc.py"]):::guard
t_tests_unit_health_test_file_nloc_py -.-> f_packages_core_src_repowise_core_analysis_health_engine_py
classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Solid arrows: code that imports the changed files (7 direct dependents, from the last indexed snapshot). Dashed: history/tests. 🔥 Hotspots touched (3)
👀 Suggested reviewers @RaghavChamadiya 📊 See the full report for this PR |
Ayush7614
left a comment
There was a problem hiding this comment.
Verified: packages/core/src/repowise/core/analysis/health/engine.py:289 adds {stem}_spec{ext} candidate alongside dot-form, fixing Ruby _spec.rb (#1768) and Crystal _spec.cr pairing for _has_paired_test_file. Covers both get_health and get_risk via shared helper. Tests in test_paired_test_basenames + test_risk parametrize cover it. LGTM.
|
Thanks @sloemo01. Reusing This is half of #1768 though, and I want to flag it because I am the one who left the other half on the thread. The issue has two heuristics missing Ruby, not one. The suffix side is what you fixed. The prefix side is still hardcoded to Python two lines above your change: candidates = {
f"test_{stem}.py",
f"{stem}_test{test_suffix}",
f"{stem}_spec{test_suffix}",Ruby minitest names its files f"test_{stem}{test_suffix}",That also picks up Elixir's Since the PR says |
Fixes #1768
Problem
Ruby's standard test layout is
<stem>_spec.rbunderspec/(underscore beforespec, not a dot). Neither test-pairing heuristic recognized it:_has_paired_test_fileinengine.pyonly had.spec.ts/.spec.js/.spec.mts/.spec.cts(dot form), so every RSpec repo read ashas_test_file: falsefromget_health._check_test_gap) delegates to the same shared heuristic, so it also reportedtest_gap: true.Fix
Added
{stem}_spec{ext}(underscore form) alongside the existing{stem}_test{ext}and dot-form.spec.*candidates. This matches Rubyuser_spec.rband, because Crystal shares the_spec.crconvention, comes along for free.Note: the
%{base}.spec.{ext}%builder previously in the risk tool was already refactored to delegate to the shared_has_paired_test_file, so the single engine.py change covers bothget_healthandget_risk.Tests
test_paired_test_basenames.py: addedtest_ruby_and_crystal_underscore_spec_pairing; oracle kept in lockstep.test_risk.py: extended the suffix-convention parametrize withlib/user.rb -> spec/user_spec.rbandsrc/user.cr -> spec/user_spec.cr.uv run ruff checkpasses; the affected tests plus the health/persistence suites pass.