From 6eb6e342d7e254c5fdc0a43e3019712b4538cee0 Mon Sep 17 00:00:00 2001 From: Maxim Vorobjov Date: Fri, 25 Oct 2019 16:48:58 +0300 Subject: [PATCH] Rebuild misc tests when any of test files change (#150) * rebuild misc tests when any of test file changes * fix build formatting * file change validation -> build_and_generate_tests --- build.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.rs b/build.rs index 3a2e6ff7d5..d25c339ca5 100644 --- a/build.rs +++ b/build.rs @@ -20,6 +20,21 @@ mod wasm_tests { use std::process::{Command, Stdio}; pub(crate) fn build_and_generate_tests() { + // Validate if any of test sources are present and if they changed + let bin_tests = std::fs::read_dir("misc_testsuite/src/bin") + .expect("wasm_tests feature requires initialized misc_testsuite: `git submodule update --init`?"); + for test in bin_tests { + if let Ok(test_file) = test { + let test_file_path = test_file + .path() + .into_os_string() + .into_string() + .expect("test file path"); + println!("cargo:rerun-if-changed={}", test_file_path); + } + } + + // Build tests to OUT_DIR (target/*/build/wasi-common-*/out/wasm32-wasi/release/*.wasm) let out_dir = PathBuf::from( env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set"), );