wasmer/lib/runtime-c-api/tests/runtime_c_api_tests.rs

48 lines
1.3 KiB
Rust
Raw Normal View History

2019-02-03 02:16:53 +00:00
use std::process::Command;
2019-02-02 04:10:36 +00:00
#[test]
fn test_c_api() {
2019-02-03 02:16:53 +00:00
let project_tests_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/tests");
2019-08-01 08:27:36 +00:00
run_command("cmake", project_tests_dir, vec!["."]);
run_command("make", project_tests_dir, vec!["-Wdev", "-Werror=dev"]);
run_command("make", project_tests_dir, vec!["test", "ARGS=\"-V\""]);
2019-02-03 02:16:53 +00:00
}
2019-08-01 08:27:36 +00:00
fn run_command(command_str: &str, dir: &str, args: Vec<&str>) {
println!("Running command: `{}` args: {:?}", command_str, args);
2019-02-03 02:16:53 +00:00
let mut command = Command::new(command_str);
2019-08-01 08:27:36 +00:00
command.args(&args);
2019-02-03 02:16:53 +00:00
command.current_dir(dir);
2019-02-03 02:16:53 +00:00
let result = command.output();
2019-02-03 02:16:53 +00:00
match result {
Ok(r) => {
println!("output:");
2019-02-03 02:16:53 +00:00
if let Some(code) = r.status.code() {
println!("status: {}", code);
} else {
println!("status: None");
}
2019-02-03 02:16:53 +00:00
println!("stdout:");
println!("{}", String::from_utf8_lossy(&r.stdout[..]));
println!("stderr:");
println!("{}", String::from_utf8_lossy(&r.stderr[..]));
2019-02-03 02:16:53 +00:00
if r.status.success() {
assert!(true)
} else {
panic!("Command failed with exit status: {:?}", r.status);
}
}
2019-02-03 02:16:53 +00:00
Err(e) => panic!("Command failed: {}", e),
}
2019-02-02 04:10:36 +00:00
}