Run the filetests as part of "cargo test".
Refactor the filetests harness so that it can be run as part of `cargo test`. And begin reorganizing the test harness code in preparation for moving it out of the src directory. - Test subcommand files are now named `test_*.rs`. - cton-util subcommand files now just export their `run` and nothing else. - src/filetest/mod.rs now also just exports `run` and nothing else. - Tests are now run in release mode (with debug assertions enabled).
This commit is contained in:
34
cranelift/tests/cton-util-test.rs
Normal file
34
cranelift/tests/cton-util-test.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
//! Run `cton-util test` on all available testcases.
|
||||
|
||||
use std::process::{Command, Output};
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::io::{self, Write};
|
||||
|
||||
/// Returns the target directory, where we can find build artifacts
|
||||
/// and such for the current configuration.
|
||||
fn get_target_dir() -> PathBuf {
|
||||
let mut path = env::current_exe().unwrap();
|
||||
path.pop(); // chop off exe name
|
||||
path.pop(); // chop off deps name
|
||||
path
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cton_util_test() {
|
||||
let mut cmd = Command::new(&get_target_dir().join("cton-util"));
|
||||
cmd.arg("test");
|
||||
|
||||
// We have testcases in the following directories:
|
||||
cmd.arg("filetests");
|
||||
cmd.arg("docs");
|
||||
|
||||
let Output {
|
||||
status,
|
||||
stdout,
|
||||
stderr,
|
||||
} = cmd.output().unwrap();
|
||||
io::stdout().write(&stdout).unwrap();
|
||||
io::stderr().write(&stderr).unwrap();
|
||||
assert!(status.success(), "failed with exit status {}", status);
|
||||
}
|
||||
Reference in New Issue
Block a user