Skip to content

Commit 980e2ca

Browse files
committed
tests: Remove timeouts and extraneous output capturing
cargo-nextest wraps each test in its own process, with a timeout and output capture. We don't need to do it in each test. This removes lots of boilerplate. Signed-off-by: Colin Walters <[email protected]>
1 parent 33b5153 commit 980e2ca

File tree

4 files changed

+292
-578
lines changed

4 files changed

+292
-578
lines changed

crates/integration-tests/src/main.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use camino::Utf8Path;
2+
use std::process::Output;
23

34
use color_eyre::eyre::{eyre, Context};
45
use color_eyre::Result;
@@ -63,6 +64,58 @@ pub(crate) fn get_alternative_test_image() -> String {
6364
}
6465
}
6566

67+
/// Captured output from a command with decoded stdout/stderr strings
68+
pub(crate) struct CapturedOutput {
69+
pub output: Output,
70+
pub stdout: String,
71+
pub stderr: String,
72+
}
73+
74+
impl CapturedOutput {
75+
/// Create from a raw Output
76+
pub fn new(output: Output) -> Self {
77+
let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
78+
let stderr = String::from_utf8_lossy(&output.stderr).into_owned();
79+
Self {
80+
output,
81+
stdout,
82+
stderr,
83+
}
84+
}
85+
86+
/// Assert that the command succeeded, printing debug info on failure
87+
pub fn assert_success(&self, context: &str) {
88+
assert!(
89+
self.output.status.success(),
90+
"{} failed: {}",
91+
context,
92+
self.stderr
93+
);
94+
}
95+
96+
/// Get the exit code
97+
pub fn exit_code(&self) -> Option<i32> {
98+
self.output.status.code()
99+
}
100+
101+
/// Check if the command succeeded
102+
pub fn success(&self) -> bool {
103+
self.output.status.success()
104+
}
105+
}
106+
107+
/// Run a command, capturing output
108+
pub(crate) fn run_command(program: &str, args: &[&str]) -> std::io::Result<CapturedOutput> {
109+
let output = std::process::Command::new(program).args(args).output()?;
110+
Ok(CapturedOutput::new(output))
111+
}
112+
113+
/// Run the bcvk command, capturing output
114+
pub(crate) fn run_bcvk(args: &[&str]) -> std::io::Result<CapturedOutput> {
115+
let bck = get_bck_command().expect("Failed to get bcvk command");
116+
run_command(&bck, args)
117+
}
118+
66119
fn test_images_list() -> Result<()> {
67120
println!("Running test: bcvk images list --json");
68121

0 commit comments

Comments
 (0)