Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Commit

Permalink
Check if testsuite exists, set target dir
Browse files Browse the repository at this point in the history
  • Loading branch information
marmistrz committed Aug 21, 2019
1 parent 1ceb8c5 commit bbed679
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ use std::process::{Command, Stdio};
fn main() {
let out_dir =
PathBuf::from(env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set"));
println!("OUT_DIR is {:?}", out_dir);
let mut out = File::create(out_dir.join("misc_testsuite_tests.rs"))
.expect("error generating test source file");

build_tests("misc_testsuite").expect("building tests");
test_directory(&mut out, "misc_testsuite").expect("generating tests");
build_tests("misc_testsuite", &out_dir).expect("building tests");
test_directory(&mut out, "misc_testsuite", &out_dir).expect("generating tests");
}

fn build_tests(testsuite: &str) -> io::Result<()> {
fn build_tests(testsuite: &str, out_dir: &Path) -> io::Result<()> {
// if the submodule has not been checked out, the build will stall
if !Path::new(&format!("{}/Cargo.toml", testsuite)).exists() {
panic!("Testsuite {} not checked out", testsuite);
}

let mut cmd = Command::new("cargo");
cmd.args(&["build", "--release", "--target=wasm32-wasi"])
cmd.args(&["build", "--release", "--target=wasm32-wasi", "--target-dir", out_dir.to_str().unwrap()])
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.current_dir(testsuite);
Expand All @@ -41,8 +47,8 @@ fn build_tests(testsuite: &str) -> io::Result<()> {
Ok(())
}

fn test_directory(out: &mut File, testsuite: &str) -> io::Result<()> {
let mut dir_entries: Vec<_> = read_dir(format!("{}/target/wasm32-wasi/release", testsuite))
fn test_directory(out: &mut File, testsuite: &str, out_dir: &Path) -> io::Result<()> {
let mut dir_entries: Vec<_> = read_dir(out_dir.join("wasm32-wasi/release"))
.expect("reading testsuite directory")
.map(|r| r.expect("reading testsuite directory entry"))
.filter(|dir_entry| {
Expand Down

0 comments on commit bbed679

Please sign in to comment.