Check if testsuite exists, set target dir
This commit is contained in:
committed by
Dan Gohman
parent
7e0e8daf46
commit
8db57bd6c6
@@ -9,7 +9,6 @@ authors = [
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "Apache-2.0 WITH LLVM-exception"
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
description = "WASI implementation in Rust"
|
description = "WASI implementation in Rust"
|
||||||
exclude = ["misc_testsuite/*.wasm"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasi-common-cbindgen = { path = "wasi-common-cbindgen" }
|
wasi-common-cbindgen = { path = "wasi-common-cbindgen" }
|
||||||
|
|||||||
30
build.rs
30
build.rs
@@ -15,19 +15,31 @@ use std::process::{Command, Stdio};
|
|||||||
fn main() {
|
fn main() {
|
||||||
let out_dir =
|
let out_dir =
|
||||||
PathBuf::from(env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set"));
|
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"))
|
let mut out = File::create(out_dir.join("misc_testsuite_tests.rs"))
|
||||||
.expect("error generating test source file");
|
.expect("error generating test source file");
|
||||||
|
|
||||||
build_tests("misc_testsuite").expect("building tests");
|
build_tests("misc_testsuite", &out_dir).expect("building tests");
|
||||||
test_directory(&mut out, "misc_testsuite").expect("generating 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");
|
let mut cmd = Command::new("cargo");
|
||||||
cmd.args(&["build", "--release", "--target=wasm32-wasi"])
|
cmd.args(&[
|
||||||
.stdout(Stdio::inherit())
|
"build",
|
||||||
.stderr(Stdio::inherit())
|
"--release",
|
||||||
.current_dir(testsuite);
|
"--target=wasm32-wasi",
|
||||||
|
"--target-dir",
|
||||||
|
out_dir.to_str().unwrap(),
|
||||||
|
])
|
||||||
|
.stdout(Stdio::inherit())
|
||||||
|
.stderr(Stdio::inherit())
|
||||||
|
.current_dir(testsuite);
|
||||||
let output = cmd.output()?;
|
let output = cmd.output()?;
|
||||||
|
|
||||||
let status = output.status;
|
let status = output.status;
|
||||||
@@ -41,8 +53,8 @@ fn build_tests(testsuite: &str) -> io::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_directory(out: &mut File, testsuite: &str) -> io::Result<()> {
|
fn test_directory(out: &mut File, testsuite: &str, out_dir: &Path) -> io::Result<()> {
|
||||||
let mut dir_entries: Vec<_> = read_dir(format!("{}/target/wasm32-wasi/release", testsuite))
|
let mut dir_entries: Vec<_> = read_dir(out_dir.join("wasm32-wasi/release"))
|
||||||
.expect("reading testsuite directory")
|
.expect("reading testsuite directory")
|
||||||
.map(|r| r.expect("reading testsuite directory entry"))
|
.map(|r| r.expect("reading testsuite directory entry"))
|
||||||
.filter(|dir_entry| {
|
.filter(|dir_entry| {
|
||||||
|
|||||||
Reference in New Issue
Block a user