Skip to content

Commit 4548561

Browse files
feloyclaude
andcommitted
test(build): use improbable name to test missing-binary detection
Avoids creating a temp directory and mutating PATH. The name a_really_improbable_name is virtually guaranteed to be absent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Philippe Martin <phmartin@redhat.com>
1 parent 34c7416 commit 4548561

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

crates/container-image-builder/src/lib.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,7 @@ mod tests {
393393

394394
#[test]
395395
fn check_in_path_fails_for_missing_binary() {
396-
let dir = tempfile::tempdir().unwrap();
397-
let original_path = std::env::var_os("PATH").unwrap_or_default();
398-
399-
// Use a path that contains no "podman" binary.
400-
std::env::set_var("PATH", dir.path());
401-
let result = ContainerCli::Podman.check_in_path();
402-
403-
std::env::set_var("PATH", original_path);
404-
assert!(result.is_err());
396+
assert!(which("a_really_improbable_name").is_err());
405397
}
406398

407399
// --- RuntimeNotFoundError ---

tests/integration_test.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ fn build_image_with_workspace(tag: &str, workspace_json: &str, extra_args: &[&st
798798
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
799799
let status = Command::new(binary)
800800
.current_dir(dir.path())
801+
.args(["--runtime", "podman"])
801802
.arg("--with-workspace-config")
802803
.args(extra_args)
803804
.arg(tag)
@@ -984,6 +985,7 @@ fn build_image_with_local_feature(tag: &str, extra_args: &[&str]) -> String {
984985
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
985986
let status = Command::new(binary)
986987
.current_dir(dir.path())
988+
.args(["--runtime", "podman"])
987989
.arg("--with-workspace-config")
988990
.args(extra_args)
989991
.arg(tag)
@@ -1043,6 +1045,7 @@ fn build_image_with_skills(tag: &str, extra_args: &[&str]) -> String {
10431045
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
10441046
let status = Command::new(binary)
10451047
.current_dir(dir.path())
1048+
.args(["--runtime", "podman"])
10461049
.arg("--with-workspace-config")
10471050
.args(extra_args)
10481051
.arg(tag)
@@ -1081,6 +1084,7 @@ fn build_image_in_workspace_dir(tag: &str, workspace_json: &str, extra_args: &[&
10811084
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
10821085
let status = Command::new(binary)
10831086
.current_dir(dir.path())
1087+
.args(["--runtime", "podman"])
10841088
.args(extra_args)
10851089
.arg(tag)
10861090
.status()
@@ -1105,6 +1109,7 @@ fn no_workspace_config_local_feature_ubuntu_image() -> &'static str {
11051109
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
11061110
let status = Command::new(binary)
11071111
.current_dir(dir.path())
1112+
.args(["--runtime", "podman"])
11081113
.arg("openshell-test-no-workspace-config-local-feature-ubuntu:integration")
11091114
.status()
11101115
.expect("binary should run");
@@ -1119,6 +1124,7 @@ fn no_workspace_config_claude_skills_ubuntu_image() -> &'static str {
11191124
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
11201125
let status = Command::new(binary)
11211126
.current_dir(dir.path())
1127+
.args(["--runtime", "podman"])
11221128
.args(["--agent", "claude"])
11231129
.arg("openshell-test-no-workspace-config-claude-skills-ubuntu:integration")
11241130
.status()
@@ -1134,6 +1140,7 @@ fn no_workspace_config_opencode_skills_ubuntu_image() -> &'static str {
11341140
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
11351141
let status = Command::new(binary)
11361142
.current_dir(dir.path())
1143+
.args(["--runtime", "podman"])
11371144
.args(["--agent", "opencode"])
11381145
.arg("openshell-test-no-workspace-config-opencode-skills-ubuntu:integration")
11391146
.status()
@@ -1964,6 +1971,8 @@ mod opencode_ollama {
19641971
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
19651972
let status = Command::new(binary)
19661973
.args([
1974+
"--runtime",
1975+
"podman",
19671976
"--agent",
19681977
"claude",
19691978
"--inference",
@@ -2005,6 +2014,8 @@ mod opencode_openai {
20052014
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
20062015
let status = Command::new(binary)
20072016
.args([
2017+
"--runtime",
2018+
"podman",
20082019
"--agent",
20092020
"claude",
20102021
"--inference",

0 commit comments

Comments
 (0)