|
1 | 1 | mod fixtures; |
2 | 2 |
|
3 | | -use std::thread::sleep; |
4 | | - |
5 | 3 | use assert_cmd::cargo::cargo_bin_cmd; |
6 | 4 | use assert_cmd::prelude::*; |
7 | 5 | use predicates::prelude::*; |
@@ -32,32 +30,46 @@ fn no_run_no_app() { |
32 | 30 | } |
33 | 31 |
|
34 | 32 | #[test] |
35 | | -fn shim_test() { |
36 | | - let s = fixtures::ContainerPathShim::new(); |
37 | | - let bin = s.install_all(); |
| 33 | +fn container_shim_test() { |
| 34 | + let fixture = fixtures::ContainerPathShim::new(); |
| 35 | + let bin = fixture.install_all(); |
38 | 36 |
|
39 | 37 | // Call each shim with dummy arguments and check the invocation logs |
40 | 38 | for shim_name in fixtures::ContainerPathShim::BIN_SHIMS { |
41 | 39 | let log_file = bin.join(format!("{}.log", shim_name)); |
42 | 40 | let shim_path = bin.join(shim_name); |
43 | 41 |
|
44 | | - std::process::Command::new(&shim_path) |
45 | | - .args(["arg1", "arg2", "--flag"]) |
46 | | - .env("TEST_INVOCATIONS_LOG", &log_file) |
47 | | - .output() |
48 | | - .expect("Failed to execute shim"); |
49 | | - |
50 | | - // Read the log file and verify it contains the expected command line |
51 | | - let log_contents = std::fs::read_to_string(&log_file).expect("Failed to read log file"); |
52 | | - |
53 | | - let expected = format!("{} arg1 arg2 --flag", shim_path.display()); |
54 | | - assert!( |
55 | | - log_contents.trim() == expected, |
56 | | - "Log file for {} should contain '{}', but got '{}'", |
57 | | - shim_name, |
58 | | - expected, |
59 | | - log_contents.trim() |
60 | | - ); |
| 42 | + for cmd in [ |
| 43 | + std::process::Command::new("sh") |
| 44 | + .args([ |
| 45 | + "-c", |
| 46 | + &format!( |
| 47 | + "{} && {shim_name} arg1 arg2 --flag", |
| 48 | + fixture.export_path_cmd() |
| 49 | + ), |
| 50 | + ]) |
| 51 | + .env("TEST_INVOCATIONS_LOG", &log_file), |
| 52 | + std::process::Command::new(shim_name) |
| 53 | + .args(["arg1", "arg2", "--flag"]) |
| 54 | + .envs(fixture.env_overrides()) |
| 55 | + .env("TEST_INVOCATIONS_LOG", &log_file), |
| 56 | + ] { |
| 57 | + let _r = cmd.output().expect("Failed to execute shim"); |
| 58 | + // eprintln!("{_r:?}"); |
| 59 | + |
| 60 | + // Read the log file and verify it contains the expected command line |
| 61 | + let log_contents = std::fs::read_to_string(&log_file).expect("Failed to read log file"); |
| 62 | + |
| 63 | + let expected = format!("{} arg1 arg2 --flag", shim_path.display()); |
| 64 | + assert!( |
| 65 | + log_contents.trim() == expected, |
| 66 | + "Log file for {} should contain '{}', but got '{}'", |
| 67 | + shim_name, |
| 68 | + expected, |
| 69 | + log_contents.trim() |
| 70 | + ); |
| 71 | + std::fs::remove_file(&log_file).expect("Failed to delete log file"); |
| 72 | + } |
61 | 73 | } |
62 | | - //sleep(std::time::Duration::from_secs(60)); |
| 74 | + //std::thread::sleep(std::time::Duration::from_secs(60)); |
63 | 75 | } |
0 commit comments