Skip to content

Commit 082a98b

Browse files
CI: Fix Go workspace tests on Windows (#1815) (#1816)
* Fix Go workspace tests failing on Windows Three Go workspace unit tests failed on the nightly Windows run, keeping main's nightly CI red. Their fixtures used /elsewhere and /nonexistent as absolute GOWORK paths, but on Windows a path with no drive is relative, so the code (like go itself) rejected them. A third test expected a forward-slash path where Windows prints a native one. Build the GOWORK fixtures under the test's temp dir so they are absolute on every platform, and match the member path with the platform separator. No product code changes. Fixes #1815 Assisted-by: Claude Code:claude-opus-5-5 * Keep remaining GOWORK test paths portable The Go crawler test still set GOWORK to /elsewhere/go.work, which on Windows is relative, so its "file elsewhere" case quietly checked an invalid GOWORK instead. Point it at an absolute path beside the project. Keep the VEX test's missing go.work outside the project, as the original /nonexistent path was. Refs #1815 Assisted-by: Claude Code:claude-opus-5-5 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ecd4924 commit 082a98b

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎crates/socket-patch-core/src/crawlers/go_crawler.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,8 +1426,10 @@ mod tests {
14261426
}
14271427
std::fs::remove_file(f.project.join("go.work")).unwrap();
14281428

1429-
// GOWORK naming a file elsewhere.
1430-
let _gowork = EnvGuard::set("GOWORK", "/elsewhere/go.work");
1429+
// GOWORK naming a file elsewhere (absolute on every platform:
1430+
// `/x` has no drive on Windows, so go rejects it as relative).
1431+
let elsewhere = f.project.parent().unwrap().join("elsewhere/go.work");
1432+
let _gowork = EnvGuard::set("GOWORK", &elsewhere.to_string_lossy());
14311433
assert_eq!(f.crawl().await, walked);
14321434
}
14331435

‎crates/socket-patch-core/src/vendor/go_workspace.rs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,9 +1138,12 @@ mod tests {
11381138
);
11391139
}
11401140
assert_eq!(resolve_with(&project, Some("off")), GoWork::None);
1141+
// Absolute on this platform (`/x` has no drive on Windows, where go
1142+
// rejects it as relative too).
1143+
let elsewhere = tmp.path().join("elsewhere").join("go.work");
11411144
assert_eq!(
1142-
resolve_with(&project, Some("/elsewhere/go.work")),
1143-
GoWork::File(PathBuf::from("/elsewhere/go.work"))
1145+
resolve_with(&project, Some(&elsewhere.to_string_lossy())),
1146+
GoWork::File(elsewhere.clone())
11441147
);
11451148
for relative in ["go.work", "../go.work"] {
11461149
assert!(
@@ -1476,7 +1479,10 @@ mod tests {
14761479
));
14771480
match ws.conflict(&root.join("a"), DEP, "v1.0.0", &ours) {
14781481
Some(c @ WorkspaceConflict::MainModule { .. }) => {
1479-
assert!(c.consequence(DEP, "v1.0.0").contains("ws/dep"), "{c:?}");
1482+
// Outside the project the member shows as a native path.
1483+
let member = Path::new("ws").join("dep");
1484+
let member = member.to_string_lossy();
1485+
assert!(c.consequence(DEP, "v1.0.0").contains(&*member), "{c:?}");
14801486
}
14811487
other => panic!("{other:?}"),
14821488
}

‎crates/socket-patch-core/src/vex/discover/golang.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,9 +1836,13 @@ mod tests {
18361836
);
18371837
}
18381838
let elsewhere = p.root().join("a").join("go.work");
1839+
// Outside the project and absolute on this platform (`/nonexistent`
1840+
// has no drive on Windows, so go rejects it as relative).
1841+
let outside = tempfile::tempdir().unwrap();
1842+
let missing = outside.path().join("nonexistent").join("go.work");
18391843
for (gowork, why) in [
18401844
("go.work".to_string(), "not an absolute path"),
1841-
("/nonexistent/go.work".to_string(), "other than"),
1845+
(missing.to_string_lossy().into_owned(), "other than"),
18421846
(elsewhere.to_string_lossy().into_owned(), "other than"),
18431847
] {
18441848
let out = extract(Some(gowork.clone())).await;

0 commit comments

Comments
 (0)