Skip to content

Commit be55025

Browse files
committed
fix(go-runner): clear mod cache before running tests
1 parent 9e75c28 commit be55025

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

go-runner/src/runner/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@ use tempfile::TempDir;
88

99
mod overlay;
1010

11-
pub fn run_cmd<P: AsRef<Path>>(
11+
fn run_cmd<P: AsRef<Path>>(
1212
profile_dir: P,
1313
dir: P,
1414
cli: &Cli,
1515
) -> anyhow::Result<(TempDir, Command)> {
1616
let (_dir, overlay_file) = overlay::get_overlay_file(profile_dir.as_ref())?;
1717

18+
// Clear the mod cache which can cause issues with `-overlay` since it's assumed to
19+
// be read-only. Tests can otherwise crash at runtime with this error:
20+
// `go: overlay contains a replacement for /home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-arm64/src/testing/benchmark.go. Files beneath GOMODCACHE (/home/runner/go/pkg/mod) must not be replaced.
21+
//
22+
// See: https://github.com/golang/go/issues/71783#issuecomment-2666541103
23+
Command::new("go")
24+
.arg("clean")
25+
.arg("-modcache")
26+
.output()
27+
.unwrap();
28+
1829
// Execute the `go test` command using the go binary, rather than the one in the PATH
1930
// to avoid running into infinite loops with the runner which tries to intercept `go test`.
2031
let go_binary = find_go_binary()?;

0 commit comments

Comments
 (0)