From c30bc58cc17f6d7ea7a43a7405587adb6f668272 Mon Sep 17 00:00:00 2001 From: Steven Zimmerman Date: Thu, 27 Aug 2026 08:07:44 -0400 Subject: [PATCH 1/3] fix(analysis): normalize probe paths before test association --- .../src/analysis/classify/related_tests.rs | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/crates/ripr/src/analysis/classify/related_tests.rs b/crates/ripr/src/analysis/classify/related_tests.rs index f05526bae83..9650c274665 100644 --- a/crates/ripr/src/analysis/classify/related_tests.rs +++ b/crates/ripr/src/analysis/classify/related_tests.rs @@ -18,12 +18,7 @@ pub(in crate::analysis) fn find_related_tests<'a>( let mut related: Vec<(&TestSummary, RelationReason)> = Vec::new(); let owner_name = owner_fn.map(|f| f.name.as_str()).unwrap_or(""); let probe_tokens = extract_identifier_tokens(&probe.expression); - let file_name = probe - .location - .file - .file_stem() - .and_then(|s| s.to_str()) - .unwrap_or(""); + let file_name = normalized_file_stem(&probe.location.file); let owner_package_prefix = owner_fn.and_then(|owner| package_prefix(&owner.file)); // #2971 ambiguity rule: a call to `owner_name` can bypass the @@ -146,7 +141,8 @@ pub(in crate::analysis) fn find_related_tests<'a>( let test_name = test.name.to_ascii_lowercase(); let owner_name_lc = owner_name.to_ascii_lowercase(); - let file_path_matches = normalize_path(&test.file).contains(file_name); + let file_path_matches = + !file_name.is_empty() && normalize_path(&test.file).contains(&file_name); let owner_name_in_test = !owner_name_lc.is_empty() && test_name.contains(&owner_name_lc); let token_in_test_name = probe_tokens .iter() @@ -212,6 +208,18 @@ fn normalize_path(path: &Path) -> String { .to_string() } +/// Extract a source-file stem after normalizing separators from either host. +/// Analysis inputs can contain paths produced on a different platform than the +/// host running the association pass. +fn normalized_file_stem(path: &Path) -> String { + normalize_path(path) + .rsplit('/') + .next() + .and_then(|file| file.rsplit_once('.').map(|(stem, _)| stem).or(Some(file))) + .unwrap_or_default() + .to_string() +} + /// #3235: one authority for recognizing an absolute path form on any host — /// Unix-rooted, Windows drive-prefixed, or host-absolute. Shared by /// `package_prefix` (which cannot derive a package scope from such a path @@ -738,6 +746,43 @@ mod tests { assert_eq!(related[0].0.name, "repo_lane_deserializes_fields_correctly"); } + #[test] + fn given_mixed_path_separators_when_same_file_probe_is_repeated_then_association_and_assertion_text_are_stable() + { + let assertion_text = "assert_eq!(config.retry_limit, 3);"; + let oracle_test = test_with_assertions( + "crates/ripr/tests/config.rs", + "config_retry_limit_is_preserved", + assertion_text, + vec![oracle_fact( + assertion_text, + OracleKind::ExactValue, + OracleStrength::Strong, + )], + ); + let index = RustIndex { + tests: vec![oracle_test], + ..RustIndex::default() + }; + let forward_probe = struct_field_probe("crates/ripr/src/config.rs", "retry_limit"); + let windows_probe = struct_field_probe("crates\\ripr\\src\\config.rs", "retry_limit"); + + let forward_related = find_related_tests(&forward_probe, None, &index, true, None); + let windows_related = find_related_tests(&windows_probe, None, &index, true, None); + + assert_eq!(forward_related.len(), 1); + assert_eq!(windows_related.len(), 1); + assert_eq!(forward_related[0].0.name, windows_related[0].0.name); + assert_eq!( + forward_related[0].0.assertions[0].text, assertion_text, + "path normalization must not rewrite assertion text" + ); + assert_eq!( + windows_related[0].0.assertions[0].text, assertion_text, + "path normalization must not rewrite assertion text" + ); + } + // --- #1054 repro --- // Two sibling struct-field probes (`open_in` and `open_cap`) are both // asserted by the SAME exact-value oracle test. Both MUST select that test From dc1807d3eab61a1d24dbdf88ed9332936848511e Mon Sep 17 00:00:00 2001 From: Steven Zimmerman Date: Thu, 27 Aug 2026 08:20:52 -0400 Subject: [PATCH 2/3] test(analysis): make platform association regression independent --- crates/ripr/src/analysis/classify/related_tests.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/ripr/src/analysis/classify/related_tests.rs b/crates/ripr/src/analysis/classify/related_tests.rs index 9650c274665..87c3073915a 100644 --- a/crates/ripr/src/analysis/classify/related_tests.rs +++ b/crates/ripr/src/analysis/classify/related_tests.rs @@ -747,12 +747,11 @@ mod tests { } #[test] - fn given_mixed_path_separators_when_same_file_probe_is_repeated_then_association_and_assertion_text_are_stable() - { - let assertion_text = "assert_eq!(config.retry_limit, 3);"; + fn given_foreign_separator_file_stem_when_associated_then_assertion_text_is_preserved() { + let assertion_text = "assert_eq!(value, 3);"; let oracle_test = test_with_assertions( "crates/ripr/tests/config.rs", - "config_retry_limit_is_preserved", + "checks_value", assertion_text, vec![oracle_fact( assertion_text, @@ -764,8 +763,8 @@ mod tests { tests: vec![oracle_test], ..RustIndex::default() }; - let forward_probe = struct_field_probe("crates/ripr/src/config.rs", "retry_limit"); - let windows_probe = struct_field_probe("crates\\ripr\\src\\config.rs", "retry_limit"); + let forward_probe = struct_field_probe("crates/ripr/src/config.rs", "marker"); + let windows_probe = struct_field_probe("crates\\ripr\\src\\config.rs", "marker"); let forward_related = find_related_tests(&forward_probe, None, &index, true, None); let windows_related = find_related_tests(&windows_probe, None, &index, true, None); @@ -773,6 +772,8 @@ mod tests { assert_eq!(forward_related.len(), 1); assert_eq!(windows_related.len(), 1); assert_eq!(forward_related[0].0.name, windows_related[0].0.name); + assert_eq!(forward_related[0].1, RelationReason::SameTestFile); + assert_eq!(windows_related[0].1, RelationReason::SameTestFile); assert_eq!( forward_related[0].0.assertions[0].text, assertion_text, "path normalization must not rewrite assertion text" From 6b48b55a7942ee3ae721c3c52197a5f4defd5636 Mon Sep 17 00:00:00 2001 From: Steven Zimmerman Date: Thu, 27 Aug 2026 23:07:44 -0400 Subject: [PATCH 3/3] fix(analysis): preserve normalized dotfile stems --- .../src/analysis/classify/related_tests.rs | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/ripr/src/analysis/classify/related_tests.rs b/crates/ripr/src/analysis/classify/related_tests.rs index 87c3073915a..2b49402fc94 100644 --- a/crates/ripr/src/analysis/classify/related_tests.rs +++ b/crates/ripr/src/analysis/classify/related_tests.rs @@ -215,7 +215,8 @@ fn normalized_file_stem(path: &Path) -> String { normalize_path(path) .rsplit('/') .next() - .and_then(|file| file.rsplit_once('.').map(|(stem, _)| stem).or(Some(file))) + .and_then(|file| Path::new(file).file_stem()) + .and_then(|stem| stem.to_str()) .unwrap_or_default() .to_string() } @@ -784,6 +785,36 @@ mod tests { ); } + #[test] + fn given_dotfile_probe_when_associated_then_only_matching_companion_is_related() { + let matching_test = test_with_assertions( + "crates/ripr/tests/.config.rs", + "checks_config_value", + "assert_eq!(value, 3);", + Vec::new(), + ); + let unrelated_test = test_with_assertions( + "crates/ripr/tests/config.rs", + "checks_value", + "assert_eq!(value, 3);", + Vec::new(), + ); + let index = RustIndex { + tests: vec![matching_test, unrelated_test], + ..RustIndex::default() + }; + let forward_probe = struct_field_probe("crates/ripr/src/.config", "marker"); + let windows_probe = struct_field_probe("crates\\ripr\\src\\.config", "marker"); + + for probe in [forward_probe, windows_probe] { + let related = find_related_tests(&probe, None, &index, true, None); + + assert_eq!(related.len(), 1); + assert_eq!(related[0].0.file, Path::new("crates/ripr/tests/.config.rs")); + assert_eq!(related[0].1, RelationReason::SameTestFile); + } + } + // --- #1054 repro --- // Two sibling struct-field probes (`open_in` and `open_cap`) are both // asserted by the SAME exact-value oracle test. Both MUST select that test