diff options
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/test.rs | 15 | ||||
| -rw-r--r-- | src/bootstrap/src/lib.rs | 33 |
2 files changed, 33 insertions, 15 deletions
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 248d831b6e3..47b0637538b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1657,8 +1657,8 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the // ensure that `libproc_macro` is available on the host. builder.ensure(compile::Std::new(compiler, compiler.host)); - // As well as the target, except for plain wasm32, which can't build it - if suite != "mir-opt" && !target.contains("wasm") && !target.contains("emscripten") { + // As well as the target + if suite != "mir-opt" { builder.ensure(TestHelpers { target }); } @@ -2511,16 +2511,7 @@ fn prepare_cargo_test( dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target))); cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); - if target.contains("emscripten") { - cargo.env( - format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), - builder.config.nodejs.as_ref().expect("nodejs not configured"), - ); - } else if target.starts_with("wasm32") { - let node = builder.config.nodejs.as_ref().expect("nodejs not configured"); - let runner = format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display()); - cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner); - } else if builder.remote_tested(target) { + if builder.remote_tested(target) { cargo.env( format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()), diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 6520b7ed089..9cbd4d367f0 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1361,9 +1361,36 @@ impl Build { /// An example of this would be a WebAssembly runtime when testing the wasm /// targets. fn runner(&self, target: TargetSelection) -> Option<String> { - let target = self.config.target_config.get(&target)?; - let runner = target.runner.as_ref()?; - Some(runner.to_owned()) + let configured_runner = + self.config.target_config.get(&target).and_then(|t| t.runner.as_ref()).map(|p| &**p); + if let Some(runner) = configured_runner { + return Some(runner.to_owned()); + } + + if target.starts_with("wasm") && target.contains("wasi") { + self.default_wasi_runner() + } else { + None + } + } + + /// When a `runner` configuration is not provided and a WASI-looking target + /// is being tested this is consulted to prove the environment to see if + /// there's a runtime already lying around that seems reasonable to use. + fn default_wasi_runner(&self) -> Option<String> { + let mut finder = crate::core::sanity::Finder::new(); + + // Look for Wasmtime, and for its default options be sure to disable + // its caching system since we're executing quite a lot of tests and + // ideally shouldn't pollute the cache too much. + if let Some(path) = finder.maybe_have("wasmtime") { + if let Ok(mut path) = path.into_os_string().into_string() { + path.push_str(" run -C cache=n --dir ."); + return Some(path); + } + } + + None } /// Returns the root of the "rootfs" image that this target will be using, |
