From 8e593506dcfa7a06ec14ac9fa9321a6023d63f52 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 9 Oct 2019 13:34:09 -0700 Subject: [PATCH] Don't run the spec_testsuite tests if the submodule isn't checked out. (#409) * Don't run the spec_testsuite tests if the submodule isn't checked out. This way, if someone checks out the repository without checking out the submodules, they can still run "cargo test". Also, fix a warning in the generated test runner code. * Print a message if the spec_testsuite submodule is not enabled. * Move the `#[cfg(test)]` to the top-level `mod`. --- build.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/build.rs b/build.rs index de13239e47..c6a8b3b3b0 100644 --- a/build.rs +++ b/build.rs @@ -19,17 +19,27 @@ fn main() { #[cfg(feature = "lightbeam")] "Lightbeam", ] { + writeln!(out, "#[cfg(test)]").expect("generating tests"); writeln!(out, "#[allow(non_snake_case)]").expect("generating tests"); writeln!(out, "mod {} {{", strategy).expect("generating tests"); test_directory(&mut out, "misc_testsuite", strategy).expect("generating tests"); test_directory(&mut out, "spec_testsuite", strategy).expect("generating tests"); - test_file( - &mut out, - "spec_testsuite/proposals/simd/simd_const.wast", - strategy, - ) - .expect("generating tests"); + // Skip running spec_testsuite tests if the submodule isn't checked out. + if read_dir("spec_testsuite") + .expect("reading testsuite directory") + .next() + .is_some() + { + test_file( + &mut out, + "spec_testsuite/proposals/simd/simd_const.wast", + strategy, + ) + .expect("generating tests"); + } else { + println!("cargo:warning=The spec testsuite is disabled. To enable, run `git submodule update --remote`."); + } writeln!(out, "}}").expect("generating tests"); }