Skip to content

Commit

Permalink
[wasmtime-api] run example as tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed Oct 29, 2019
1 parent bf526b6 commit bec9016
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions wasmtime-api/tests/examples.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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::var("CARGO_MANIFEST_DIR").unwrap_or(".".to_string());
debug_assert!(
Command::new(cargo)
.current_dir(pkg_dir)
.stdout(Stdio::null())
.args(&["run", "-q", "--example", name])
.status()
.expect("success")
.success(),
"unabled to executed 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");
}

#[test]
fn test_run_multi_example() {
run_example("multi");
}

0 comments on commit bec9016

Please sign in to comment.