[wasmtime-api] run examples as tests (#466)
* [wasmtime-api] run example as tests * Update wasmtime-api/tests/examples.rs Co-Authored-By: Nick Fitzgerald <fitzgen@gmail.com> * disable multi example test on windows
This commit is contained in:
39
wasmtime-api/tests/examples.rs
Normal file
39
wasmtime-api/tests/examples.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
|
fn run_example(name: &'static str) {
|
||||||
|
let cargo = env::var("CARGO").unwrap_or("cargo".to_string());
|
||||||
|
let pkg_dir = env!("CARGO_MANIFEST_DIR");
|
||||||
|
assert!(
|
||||||
|
Command::new(cargo)
|
||||||
|
.current_dir(pkg_dir)
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.args(&["run", "-q", "--example", name])
|
||||||
|
.status()
|
||||||
|
.expect("success")
|
||||||
|
.success(),
|
||||||
|
"failed to execute the example '{}'",
|
||||||
|
name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_run_hello_example() {
|
||||||
|
run_example("hello");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_run_gcd_example() {
|
||||||
|
run_example("gcd");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_run_memory_example() {
|
||||||
|
run_example("memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
#[test]
|
||||||
|
fn test_run_multi_example() {
|
||||||
|
run_example("multi");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user