test: keep cargo test output quiet with per-test logs and a failure matrix
cargo test used to be unreadable: subprocesses inherited the terminal, so dpkg-buildpackage, apt and configure output interleaved with the harness summary, and env_logger lines from parallel tests crossed each other. New test_support module, compiled into test binaries only (inert stubs otherwise) and initialized before main via .init_array: - all log output goes to target/pkh-test-logs/<test>.log, one file per test thread, so concurrent tests never interleave - context-launched commands are captured line by line into the same file (driver-level wrapper); test-code spawns use run_logged() - a panic hook records failures and an atexit callback prints a matrix (test name, panic location, message, log path) after the libtest summary; tests panicking on purpose can opt out with a guard Also fixes two test bugs found on the way: - diff_checkbuilddeps_matrix compared dpkg-checkbuilddeps diagnostics against English messages without pinning the locale - run_source_build in differential tests now captures output like the live-UI path does
This commit is contained in:
+3
-1
@@ -311,7 +311,9 @@ impl Context {
|
||||
overlay_mounts: std::sync::Mutex::new(Vec::new()),
|
||||
}),
|
||||
};
|
||||
*driver_lock = Some(driver);
|
||||
// In test runs, commands whose output would inherit the terminal
|
||||
// are captured into the per-test log file instead
|
||||
*driver_lock = Some(crate::test_support::wrap_driver(driver));
|
||||
}
|
||||
driver_lock
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ mod ssh;
|
||||
mod unshare;
|
||||
|
||||
pub use api::{Context, ContextCommand, ContextConfig, LineSink, Stream};
|
||||
// The driver trait is implementation detail of the context API; it is only
|
||||
// needed crate-internally (test-run capture wrapper), so keep it out of the
|
||||
// public surface (and its documentation requirement).
|
||||
pub(crate) use api::ContextDriver;
|
||||
pub use manager::ContextManager;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user