diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index df9c7d27399..f62bf0af48b 100644 --- a/crates/cli/tests/reference.rs +++ b/crates/cli/tests/reference.rs @@ -42,7 +42,7 @@ fn main() -> Result<()> { let filter = env::args().nth(1); let mut tests = Vec::new(); - let dir = env::current_dir()?.join("tests/reference"); + let dir = repo_root().join("crates/cli/tests/reference"); for entry in dir.read_dir()? { let path = entry?.path(); if path.extension().and_then(|s| s.to_str()) != Some("rs") { @@ -114,7 +114,11 @@ fn runtest(test: &Path) -> Result<()> { .arg("build") .arg("--target") .arg("wasm32-unknown-unknown") - .env("CARGO_TARGET_DIR", &target_dir); + .env("CARGO_TARGET_DIR", &target_dir) + .env( + "CARGO_ENCODED_RUSTFLAGS", + "-Ctarget-feature=-multivalue,-reference-types", + ); exec(&mut cargo)?; let wasm = target_dir @@ -134,10 +138,10 @@ fn runtest(test: &Path) -> Result<()> { exec(&mut bindgen)?; if !contents.contains("async") { - let js = fs::read_to_string(td.path().join("reference_test_bg.js"))?; - assert_same(&js, &test.with_extension("js"))?; let wat = sanitize_wasm(&td.path().join("reference_test_bg.wasm"))?; assert_same(&wat, &test.with_extension("wat"))?; + let js = fs::read_to_string(td.path().join("reference_test_bg.js"))?; + assert_same(&js, &test.with_extension("js"))?; } let d_ts = fs::read_to_string(td.path().join("reference_test.d.ts"))?; assert_same(&d_ts, &test.with_extension("d.ts"))?; @@ -224,19 +228,15 @@ fn diff(a: &str, b: &str) -> Result<()> { } fn target_dir() -> PathBuf { - let mut dir = env::current_exe().unwrap(); - dir.pop(); // current exe - if dir.ends_with("deps") { - dir.pop(); - } - dir.pop(); // debug and/or release - dir + repo_root().join("target/tests/reference") } fn repo_root() -> PathBuf { let mut repo_root = env::current_dir().unwrap(); - repo_root.pop(); // remove 'cli' - repo_root.pop(); // remove 'crates' + if repo_root.file_name() == Some("cli".as_ref()) { + repo_root.pop(); // remove 'cli' + repo_root.pop(); // remove 'crates' + } repo_root }