From 0424f8c3be8d8759a2ff9bbb753241824b3817fc Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:53:45 -0600 Subject: [PATCH 1/2] Fix id fake compiler shebang in sandbox tests --- pkgs/id/flake.nix | 6 ++++++ pkgs/id/src/world_compile.rs | 39 ++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 705ab92e91..d5a9634fbf 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -824,6 +824,9 @@ "--skip" "serve_tests" ]; + preCheck = '' + export ID_TEST_FAKE_SH="${pkgs.stdenv.shell}" + ''; meta = commonMeta // { description = "A peer-to-peer file sharing CLI built with Iroh (with web UI)"; @@ -873,6 +876,9 @@ "--skip" "serve_tests" ]; + preCheck = '' + export ID_TEST_FAKE_SH="${pkgs.stdenv.shell}" + ''; meta = commonMeta // { description = "A peer-to-peer file sharing CLI built with Iroh"; diff --git a/pkgs/id/src/world_compile.rs b/pkgs/id/src/world_compile.rs index f9a15b83c5..82f5f65037 100644 --- a/pkgs/id/src/world_compile.rs +++ b/pkgs/id/src/world_compile.rs @@ -806,20 +806,43 @@ mod tests { } #[cfg(unix)] - fn fake_compiler(script: &str) -> (tempfile::TempDir, PathBuf) { + fn fake_compiler(script: &str) -> Option<(tempfile::TempDir, PathBuf)> { + use std::os::unix::fs::PermissionsExt as _; + + let is_executable = |path: &Path| { + std::fs::metadata(path).is_ok_and(|metadata| { + metadata.is_file() && metadata.permissions().mode() & 0o111 != 0 + }) + }; + let interpreter = std::env::var_os("ID_TEST_FAKE_SH") + .map(PathBuf::from) + .filter(|path| is_executable(path)) + .or_else(|| { + let path = PathBuf::from("/bin/sh"); + is_executable(&path).then_some(path) + }); + let Some(interpreter) = interpreter else { + eprintln!( + "skipping fake compiler probe test: neither ID_TEST_FAKE_SH nor /bin/sh is executable" + ); + return None; + }; + let dir = tempfile::tempdir().expect("tempdir"); let path = dir.path().join("fake-roc"); + let script = format!("#!{}\n{script}", interpreter.display()); std::fs::write(&path, script).expect("write fake compiler"); - use std::os::unix::fs::PermissionsExt as _; std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o755)) .expect("chmod fake compiler"); - (dir, path) + Some((dir, path)) } #[cfg(unix)] #[test] fn version_probe_records_the_reported_version() { - let (_dir, bin) = fake_compiler("#!/bin/sh\necho 'roc version 9.9-test'\n"); + let Some((_dir, bin)) = fake_compiler("echo 'roc version 9.9-test'\n") else { + return; + }; assert_eq!( probe_compiler_version(&bin, Duration::from_secs(5)), "roc version 9.9-test" @@ -832,7 +855,9 @@ mod tests { // A compiler that hangs while reporting its version must be // killed at the probe bound and recorded as unavailable, not // block the compile forever (Codex P2 on PR #4263). - let (_dir, bin) = fake_compiler("#!/bin/sh\nsleep 30\n"); + let Some((_dir, bin)) = fake_compiler("sleep 30\n") else { + return; + }; let started = std::time::Instant::now(); assert_eq!(probe_compiler_version(&bin, Duration::from_millis(200)), ""); assert!(started.elapsed() < Duration::from_secs(5)); @@ -841,7 +866,9 @@ mod tests { #[cfg(unix)] #[test] fn version_probe_failure_records_empty() { - let (_dir, bin) = fake_compiler("#!/bin/sh\nexit 3\n"); + let Some((_dir, bin)) = fake_compiler("exit 3\n") else { + return; + }; assert_eq!(probe_compiler_version(&bin, Duration::from_secs(5)), ""); } From def48a0b37110d1b578228da87f3d5e9654afe7b Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Tue, 10 Nov 2026 17:08:33 -0600 Subject: [PATCH 2/2] fix(id): provide ID_TEST_FAKE_SH to flake check derivations too (#5926) --- pkgs/id/flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index d5a9634fbf..cc5bafb14d 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -180,6 +180,9 @@ CARGO_INCREMENTAL = "0"; CARGO_PROFILE_TEST_DEBUG = "line-tables-only"; CARGO_PROFILE_DEV_DEBUG = "line-tables-only"; + # Fake-compiler probe tests need a real interpreter for their + # shebang in the sandbox, where /bin/sh does not exist (#5926). + ID_TEST_FAKE_SH = "${pkgs.stdenv.shell}"; src = ./.; inherit buildInputs; nativeBuildInputs =