From 1786f82ec17ccaeefecf194a14a5d9e5f82a25d5 Mon Sep 17 00:00:00 2001 From: Linwei Shang Date: Fri, 1 May 2026 16:31:59 -0400 Subject: [PATCH 1/3] fix(sync-plugin): skip wasm32-wasip2 test fixture build for non-test builds Fixes #543 Co-Authored-By: Claude Sonnet 4.6 --- crates/icp-sync-plugin/build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/icp-sync-plugin/build.rs b/crates/icp-sync-plugin/build.rs index f88d5374..516ad19a 100644 --- a/crates/icp-sync-plugin/build.rs +++ b/crates/icp-sync-plugin/build.rs @@ -6,7 +6,9 @@ fn main() { println!("cargo:rerun-if-changed=tests/fixtures/test-plugin/src/lib.rs"); println!("cargo:rerun-if-changed=tests/fixtures/test-plugin/Cargo.toml"); - build_test_fixture(); + if std::env::var("CARGO_CFG_TEST").is_ok() { + build_test_fixture(); + } } fn build_test_fixture() { From 0976f9a26703f23fe830a85b74005ca38395949c Mon Sep 17 00:00:00 2001 From: Linwei Shang Date: Fri, 1 May 2026 16:42:20 -0400 Subject: [PATCH 2/3] fix(sync-plugin): skip wasm32-wasip2 test fixture build for non-test builds CARGO_CFG_TEST is not set by Cargo for build scripts, so instead gate the fixture build on whether the wasm32-wasip2 target is installed (checked via rustc sysroot). Fixture-dependent tests use option_env! and return early when the fixture was not built, so they compile and pass on machines without the wasm32-wasip2 target. Fixes #543 Co-Authored-By: Claude Sonnet 4.6 --- crates/icp-sync-plugin/build.rs | 15 ++++++++++++++- crates/icp-sync-plugin/src/runtime.rs | 16 ++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/crates/icp-sync-plugin/build.rs b/crates/icp-sync-plugin/build.rs index 516ad19a..f83337f9 100644 --- a/crates/icp-sync-plugin/build.rs +++ b/crates/icp-sync-plugin/build.rs @@ -6,11 +6,24 @@ fn main() { println!("cargo:rerun-if-changed=tests/fixtures/test-plugin/src/lib.rs"); println!("cargo:rerun-if-changed=tests/fixtures/test-plugin/Cargo.toml"); - if std::env::var("CARGO_CFG_TEST").is_ok() { + if wasm32_wasip2_is_installed() { build_test_fixture(); } } +fn wasm32_wasip2_is_installed() -> bool { + let Ok(output) = Command::new("rustc").args(["--print", "sysroot"]).output() else { + return false; + }; + if !output.status.success() { + return false; + } + let sysroot = String::from_utf8_lossy(&output.stdout); + std::path::Path::new(sysroot.trim()) + .join("lib/rustlib/wasm32-wasip2") + .exists() +} + fn build_test_fixture() { let manifest_dir = Utf8PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); let out_dir = Utf8PathBuf::from(std::env::var("OUT_DIR").unwrap()); diff --git a/crates/icp-sync-plugin/src/runtime.rs b/crates/icp-sync-plugin/src/runtime.rs index 0da842da..16674af2 100644 --- a/crates/icp-sync-plugin/src/runtime.rs +++ b/crates/icp-sync-plugin/src/runtime.rs @@ -363,7 +363,9 @@ mod tests { #[test] fn preopen_dir_error_on_missing_dir() { - let wasm_path = env!("TEST_PLUGIN_WASM"); + let Some(wasm_path) = option_env!("TEST_PLUGIN_WASM") else { + return; + }; let result = run_plugin( wasm_path.into(), ".".into(), @@ -381,7 +383,9 @@ mod tests { #[test] fn plugin_success_returns_ok() { - let wasm_path = env!("TEST_PLUGIN_WASM"); + let Some(wasm_path) = option_env!("TEST_PLUGIN_WASM") else { + return; + }; let result = run_plugin( wasm_path.into(), ".".into(), @@ -399,7 +403,9 @@ mod tests { #[test] fn plugin_failure_maps_to_run_plugin_error() { - let wasm_path = env!("TEST_PLUGIN_WASM"); + let Some(wasm_path) = option_env!("TEST_PLUGIN_WASM") else { + return; + }; let result = run_plugin( wasm_path.into(), ".".into(), @@ -420,7 +426,9 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn plugin_stdout_forwarded_through_stdio_channel() { - let wasm_path = env!("TEST_PLUGIN_WASM"); + let Some(wasm_path) = option_env!("TEST_PLUGIN_WASM") else { + return; + }; let (tx, mut rx) = tokio::sync::mpsc::channel::(16); let result = tokio::task::block_in_place(|| { run_plugin( From daac36b2e118b14c2fb1c34bda534ea640a029b2 Mon Sep 17 00:00:00 2001 From: Linwei Shang Date: Fri, 1 May 2026 16:51:47 -0400 Subject: [PATCH 3/3] fix(sync-plugin): use camino Utf8PathBuf instead of std Path in build.rs Co-Authored-By: Claude Sonnet 4.6 --- crates/icp-sync-plugin/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/icp-sync-plugin/build.rs b/crates/icp-sync-plugin/build.rs index f83337f9..cbe6461f 100644 --- a/crates/icp-sync-plugin/build.rs +++ b/crates/icp-sync-plugin/build.rs @@ -19,7 +19,7 @@ fn wasm32_wasip2_is_installed() -> bool { return false; } let sysroot = String::from_utf8_lossy(&output.stdout); - std::path::Path::new(sysroot.trim()) + Utf8PathBuf::from(sysroot.trim()) .join("lib/rustlib/wasm32-wasip2") .exists() }