Skip to content

Commit 06f9f9b

Browse files
jamesadevineCopilot
andcommitted
fix: use platform-appropriate absolute paths in path fallback tests
The fallback tests used hardcoded Unix paths (/home/user/agents/ctf.md) which are not recognised as absolute on Windows by Path::is_absolute() (no drive letter). Replace with tempfile::TempDir which produces real absolute paths on any platform. This keeps normalize_relative_path clean — no platform-specific hacks needed — while making the tests genuinely cross-platform. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7d0e541 commit 06f9f9b

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/compile/common.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,17 +1220,22 @@ mod tests {
12201220

12211221
#[test]
12221222
fn test_generate_source_path_absolute_falls_back_to_filename() {
1223-
// /home/user/agents/ctf.md is not inside a git repo, so we fall back
1223+
// An absolute path that is NOT inside a git repo should fall back
12241224
// to filename-only to avoid embedding a machine-specific absolute path.
1225-
let path = std::path::Path::new("/home/user/agents/ctf.md");
1226-
let result = generate_source_path(path);
1225+
// Use a real temp dir so the path is genuinely absolute on any OS.
1226+
let tmp = tempfile::TempDir::new().unwrap();
1227+
let abs_path = tmp.path().join("agents").join("ctf.md");
1228+
// No .git marker — find_git_root will walk up and find nothing
1229+
// (temp dirs are outside any repo).
1230+
let result = generate_source_path(&abs_path);
12271231
assert_eq!(result, "{{ workspace }}/ctf.md");
12281232
}
12291233

12301234
#[test]
12311235
fn test_generate_pipeline_path_absolute_falls_back_to_filename() {
1232-
let path = std::path::Path::new("/home/user/agents/ctf.yml");
1233-
let result = generate_pipeline_path(path);
1236+
let tmp = tempfile::TempDir::new().unwrap();
1237+
let abs_path = tmp.path().join("agents").join("ctf.yml");
1238+
let result = generate_pipeline_path(&abs_path);
12341239
assert_eq!(result, "{{ workspace }}/ctf.yml");
12351240
}
12361241

0 commit comments

Comments
 (0)