Skip to content

Commit de7016b

Browse files
committed
Prebuild all tests
1 parent 2e5f630 commit de7016b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/difftests/bin/src/main.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use anyhow::Result;
2-
use std::{env, process};
2+
use std::{
3+
env,
4+
process::{self, Command},
5+
};
36
use tester::{
47
ColorConfig, DynTestName, OutputFormat, RunIgnored, ShouldPanic, TestDesc, TestDescAndFn,
58
TestFn, TestType, run_tests_console,
@@ -66,6 +69,25 @@ fn main() -> Result<()> {
6669
process::exit(1);
6770
}
6871

72+
// We build first to ensure that the tests are compiled before running them and to
73+
// passthrough stdout and stderr from cargo to help debugging.
74+
let mut cmd = Command::new("cargo");
75+
let cmd = cmd
76+
.arg("build")
77+
.arg("--release")
78+
.current_dir(&base)
79+
.stderr(std::process::Stdio::inherit())
80+
.stdout(std::process::Stdio::inherit());
81+
tracing::debug!("Running cargo command: {:?}", cmd);
82+
83+
let output = cmd.output().expect("build output");
84+
let exit_code = output.status.code().unwrap_or(-1);
85+
tracing::debug!("Cargo build exited with code {}", exit_code);
86+
if !output.status.success() {
87+
tracing::error!("Cargo build failed");
88+
process::exit(exit_code);
89+
}
90+
6991
let tests: Vec<TestDescAndFn> = test_cases
7092
.into_iter()
7193
.map(|case| {

0 commit comments

Comments
 (0)