From b457b35de83b16ced62245125f5c6a7b66563557 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 20 Oct 2024 14:27:38 +0200 Subject: [PATCH 1/5] Disable `multivalue` in tests --- crates/cli/tests/reference.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index df9c7d27399..f4dd8093058 100644 --- a/crates/cli/tests/reference.rs +++ b/crates/cli/tests/reference.rs @@ -114,6 +114,9 @@ fn runtest(test: &Path) -> Result<()> { .arg("build") .arg("--target") .arg("wasm32-unknown-unknown") + .arg("--") + .arg("-C") + .arg("target-feature=-multivalue") .env("CARGO_TARGET_DIR", &target_dir); exec(&mut cargo)?; From 43dbda402a53cb2236a22d53d6f00fe5831f2e19 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 20 Oct 2024 15:29:56 +0200 Subject: [PATCH 2/5] Next try --- crates/cli/tests/reference.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index f4dd8093058..f3e0d33960d 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,10 +114,8 @@ fn runtest(test: &Path) -> Result<()> { .arg("build") .arg("--target") .arg("wasm32-unknown-unknown") - .arg("--") - .arg("-C") - .arg("target-feature=-multivalue") - .env("CARGO_TARGET_DIR", &target_dir); + .env("CARGO_TARGET_DIR", &target_dir) + .env("CARGO_ENCODED_RUSTFLAGS", "-Ctarget-feature=-multivalue"); exec(&mut cargo)?; let wasm = target_dir @@ -227,19 +225,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 } From 92f68681c729be1a06e8bef46d54f1eb07141362 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 20 Oct 2024 15:49:12 +0200 Subject: [PATCH 3/5] Disable `reference-types` as well --- crates/cli/tests/reference.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index f3e0d33960d..5df804e3784 100644 --- a/crates/cli/tests/reference.rs +++ b/crates/cli/tests/reference.rs @@ -115,7 +115,7 @@ fn runtest(test: &Path) -> Result<()> { .arg("--target") .arg("wasm32-unknown-unknown") .env("CARGO_TARGET_DIR", &target_dir) - .env("CARGO_ENCODED_RUSTFLAGS", "-Ctarget-feature=-multivalue"); + .env("CARGO_ENCODED_RUSTFLAGS", "-Ctarget-feature=-multivalue,-reference-types"); exec(&mut cargo)?; let wasm = target_dir From 2dc82420706f6af37e62d5404b600fb1c3ea80f2 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 20 Oct 2024 15:51:14 +0200 Subject: [PATCH 4/5] format --- crates/cli/tests/reference.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index 5df804e3784..83c54dea79d 100644 --- a/crates/cli/tests/reference.rs +++ b/crates/cli/tests/reference.rs @@ -115,7 +115,10 @@ fn runtest(test: &Path) -> Result<()> { .arg("--target") .arg("wasm32-unknown-unknown") .env("CARGO_TARGET_DIR", &target_dir) - .env("CARGO_ENCODED_RUSTFLAGS", "-Ctarget-feature=-multivalue,-reference-types"); + .env( + "CARGO_ENCODED_RUSTFLAGS", + "-Ctarget-feature=-multivalue,-reference-types", + ); exec(&mut cargo)?; let wasm = target_dir From 10c315c2808ba50b5653210c3e369a86b36d04e3 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 20 Oct 2024 15:54:31 +0200 Subject: [PATCH 5/5] show wasm changes first --- crates/cli/tests/reference.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index 83c54dea79d..f62bf0af48b 100644 --- a/crates/cli/tests/reference.rs +++ b/crates/cli/tests/reference.rs @@ -138,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"))?;