forked from wasmerio/wasmer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run cmake tests as part of a rust test
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
use std::process::Command; | ||
|
||
#[test] | ||
fn test_c_api() { | ||
// TODO run `cmake . && make && make test` | ||
let project_tests_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/tests"); | ||
run_command("cmake", project_tests_dir, Some(".")); | ||
run_command("make", project_tests_dir, None); | ||
run_command("make", project_tests_dir, Some("test")); | ||
} | ||
|
||
fn run_command(command_str: &str, dir: &str, arg: Option<&str>) { | ||
println!("Running command: `{}` arg: {:?}", command_str, arg); | ||
let mut command = Command::new(command_str); | ||
if let Some(a) = arg { | ||
command.arg(a); | ||
} | ||
command.current_dir(dir); | ||
let result = command.output(); | ||
match result { | ||
Ok(r) => { | ||
println!("output:"); | ||
if let Some(code) = r.status.code() { | ||
println!("status: {}", code); | ||
} else { | ||
println!("status: None"); | ||
} | ||
println!("stdout:"); | ||
println!("{}", String::from_utf8_lossy(&r.stdout[..])); | ||
println!("stderr:"); | ||
println!("{}", String::from_utf8_lossy(&r.stderr[..])); | ||
if r.status.success() { | ||
assert!(true) | ||
} else { | ||
panic!("Command failed with exit status: {:?}", r.status); | ||
} | ||
} | ||
Err(e) => panic!("Command failed: {}", e), | ||
} | ||
} |