@@ -1360,9 +1360,36 @@ impl Build {
1360
1360
/// An example of this would be a WebAssembly runtime when testing the wasm
1361
1361
/// targets.
1362
1362
fn runner(&self, target: TargetSelection) -> Option<String> {
1363
- let target = self.config.target_config.get(&target)?;
1364
- let runner = target.runner.as_ref()?;
1365
- Some(runner.to_owned())
1363
+ let configured_runner =
1364
+ self.config.target_config.get(&target).and_then(|t| t.runner.as_ref()).map(|p| &**p);
1365
+ if let Some(runner) = configured_runner {
1366
+ return Some(runner.to_owned());
1367
+ }
1368
+
1369
+ if target.starts_with("wasm") && target.contains("wasi") {
1370
+ self.default_wasi_runner()
1371
+ } else {
1372
+ None
1373
+ }
1374
+ }
1375
+
1376
+ /// When a `runner` configuration is not provided and a WASI-looking target
1377
+ /// is being tested this is consulted to prove the environment to see if
1378
+ /// there's a runtime already lying around that seems reasonable to use.
1379
+ fn default_wasi_runner(&self) -> Option<String> {
1380
+ let mut finder = crate::core::sanity::Finder::new();
1381
+
1382
+ // Look for Wasmtime, and for its default options be sure to disable
1383
+ // its caching system since we're executing quite a lot of tests and
1384
+ // ideally shouldn't pollute the cache too much.
1385
+ if let Some(path) = finder.maybe_have("wasmtime") {
1386
+ if let Ok(mut path) = path.into_os_string().into_string() {
1387
+ path.push_str(" run -C cache=n --dir .");
1388
+ return Some(path);
1389
+ }
1390
+ }
1391
+
1392
+ None
1366
1393
}
1367
1394
1368
1395
/// Returns the root of the "rootfs" image that this target will be using,
0 commit comments