From 782b9ed649bce706099e6d32cb873deffadc6de3 Mon Sep 17 00:00:00 2001 From: Mark Birger Date: Fri, 5 Jun 2026 21:52:46 +0200 Subject: [PATCH] tests/opa: normalize path separators in folder filter on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `run_opa_tests` builds `path_dir_str` from `path.strip_prefix(...).to_string_lossy()`, which on Windows yields strings with backslash separators (e.g. `v0\aggregates`). The folder filter then does an exact-string comparison against the CLI arguments: let run_test = folders.is_empty() || folders.iter().any(|f| &path_dir_str == f); CLI arguments use forward slashes (`v0/aggregates`), so on Windows the comparison never matches, no tests are selected, and the function bails with `"no matching tests found"`. This blocks the `cargo xtask pre-push` hook for any Windows contributor. Normalize `path_dir_str` to use forward slashes at construction time. Reproduces before the fix as `cargo test ... --test opa -- v1/aggregates` exiting 1 with `no matching tests found`; after the fix the same command runs 72 cases and the full hook command runs 2861 / 0 across 188 folders. The duplicate platform check at the `is_rego_v0_test` site (`path_dir_str.starts_with("v0/") || path_dir.starts_with("v0\\")`) is left intact to keep the change minimal — the backslash branch becomes redundant but is harmless. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/opa.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/opa.rs b/tests/opa.rs index e3dade28..5392b644 100644 --- a/tests/opa.rs +++ b/tests/opa.rs @@ -380,7 +380,11 @@ fn run_opa_tests(opa_tests_dir: String, folders: &[String]) -> Result<()> { } let path = Path::new(&path_str); let path_dir = path.strip_prefix(tests_path)?.parent().unwrap(); - let path_dir_str = path_dir.to_string_lossy().to_string(); + // Normalize to forward slashes so the folder filter at the + // `folders.iter().any(|f| &path_dir_str == f)` check below matches + // CLI arguments like `v0/aggregates` on Windows, where + // `to_string_lossy` yields backslash separators by default. + let path_dir_str = path_dir.to_string_lossy().replace('\\', "/"); let folder_name = folder_name_from_path(path_dir); let skip_rvm_for_folder = folder_name .as_deref()