1 use std::path::Path; 2 use std::process::Command; 3 4 #[cfg(feature = "component")] 5 pub mod component; 6 #[cfg(feature = "component-fuzz")] 7 pub mod component_fuzz; 8 #[cfg(feature = "wasmtime-wast")] 9 pub mod wasmtime_wast; 10 #[cfg(feature = "wast")] 11 pub mod wast; 12 cargo_test_runner() -> Option<String>13pub fn cargo_test_runner() -> Option<String> { 14 // Note that this technically should look for the current target as well 15 // instead of picking "any runner", but that's left for a future 16 // refactoring. 17 let (_, runner) = std::env::vars() 18 .filter(|(k, _v)| k.starts_with("CARGO_TARGET") && k.ends_with("RUNNER")) 19 .next()?; 20 Some(runner) 21 } 22 command(bin: impl AsRef<Path>) -> Command23pub fn command(bin: impl AsRef<Path>) -> Command { 24 let bin = bin.as_ref(); 25 match cargo_test_runner() { 26 Some(runner) => { 27 let mut parts = runner.split_whitespace(); 28 let mut cmd = Command::new(parts.next().unwrap()); 29 for arg in parts { 30 cmd.arg(arg); 31 } 32 cmd.arg(bin); 33 cmd 34 } 35 None => Command::new(bin), 36 } 37 } 38