fix(import): junit import — stop overwriting + restore test→artifact link#302
Merged
Merged
Conversation
…link User-reported regressions against `rivet import-results --format junit`: **Bug #1: silent overwrite on re-import.** `suite_to_run` built `run_id = format!("junit-{safe_name}")` from the testsuite name only, so two CI runs of the same suite produced identical filenames and the second import wiped the first. Fix: append a disambiguator to the run_id. When the JUnit `<testsuite timestamp="...">` attribute is present (most CI tooling emits it), slugify it: `2026-05-17T06-35-44Z`. When absent, hash the suite's case list (name, classname, outcome variant) and append as 16-hex DefaultHasher digest. Identical re-imports of the same artefact remain idempotent (same hash → same filename → no churn); different content distinguishes itself. **Bug #2: test→artifact link dropped on cargo-nextest output.** `artifact_id_for` has 4 heuristics; the fallback emits a literal `"classname.name"` concatenation that the test-coverage report cannot join back to any artifact. cargo-nextest doesn't bracket `[REQ-NNN]` or use the artifact ID as classname, so most rivet-on-rust projects hit the fallback. Fix: hook the JUnit importer into `test_scanner`. New public `parse_junit_xml_with_markers(xml, markers)` adds a 5th heuristic — when the existing fallback fires, look up a marker whose `test_name` matches the case name (exact or suffix with separator). The CLI (`cmd_import_results_junit`) scans the project's `src/`+`tests/` for `// rivet: verifies REQ-NNN` markers before parsing the XML, then passes them to the new function. Bracketed and direct-classname IDs are preserved (they short-circuit before the marker lookup). Existing `parse_junit_xml` kept working unchanged (delegates to the new path with an empty marker slice). No schema changes. Tests added (6): - run_id_includes_timestamp_when_present - run_id_stable_hash_when_no_timestamp - run_id_different_hash_when_content_differs - marker_lookup_supplies_artifact_id_when_fallback_concat - marker_lookup_does_not_override_explicit_bracket - marker_lookup_returns_fallback_when_no_match Workspace: 1003 lib tests pass (was 996, +7). Clippy clean. Format clean. Trace: skip Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
📐 Rivet artifact deltaNo artifact changes in this PR. Code-only changes (renderer, CLI wiring, tests) don't touch the artifact graph. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User-reported regressions
Two bugs against `rivet import-results --format junit`:
Fixes
Bug #1 — `suite_to_run` now appends a disambiguator to `run_id`:
Bug #2 — new public `parse_junit_xml_with_markers(xml, markers)` adds a 5th heuristic to `artifact_id_for`. When the existing fallback fires, look up a marker whose `test_name` matches the case name. The CLI (`cmd_import_results_junit`) scans the project's `src/`+`tests/` for `// rivet: verifies REQ-NNN` markers before parsing. Bracketed/direct-classname IDs short-circuit (existing behavior).
Existing `parse_junit_xml` kept working — delegates to the new path with empty markers.
Test plan
NOT in this PR
🤖 Generated with Claude Code