From b58d61cfb7a6e6964ed576f975373840f6fe4bfc Mon Sep 17 00:00:00 2001 From: osobh Date: Sat, 26 Sep 2026 00:06:26 -0500 Subject: [PATCH] test(wasm): accept a zstd read when the build has the filter cargo test --workspace unifies clawhdf5-format/zstd on (another member enables it), so the native interop test read the Zstd dataset that the wasm build refuses. The fixture now records its values plus the error the wasm build must give; the native test accepts either, the Node test of the real wasm package still requires the error. Co-Authored-By: Claude Opus 5.5 (1M context) --- crates/clawhdf5-wasm/tests/h5py_interop.rs | 13 ++++++++++--- examples/wasm-viewer/test/make_fixture.py | 6 ++++-- examples/wasm-viewer/test/test.mjs | 6 ++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/crates/clawhdf5-wasm/tests/h5py_interop.rs b/crates/clawhdf5-wasm/tests/h5py_interop.rs index a70d8bd..7ef60ab 100644 --- a/crates/clawhdf5-wasm/tests/h5py_interop.rs +++ b/crates/clawhdf5-wasm/tests/h5py_interop.rs @@ -166,9 +166,16 @@ fn check_file(dir: &Path, file: &str, exp: &Value) { for (path, want) in exp["datasets"].as_object().unwrap() { let kind = want["kind"].as_str().unwrap(); - let a = r - .read(path, None) - .unwrap_or_else(|e| panic!("{file}:{path}: {e}")); + let a = match (r.read(path, None), want["unavailable"].as_str()) { + (Ok(a), _) => a, + // A filter this build may lack (zstd: the wasm build has it + // off, a workspace build may unify it on) must fail clearly. + (Err(e), Some(why)) => { + assert!(e.contains(why), "{file}:{path}: {e}"); + continue; + } + (Err(e), None) => panic!("{file}:{path}: {e}"), + }; assert_eq!(a.shape, shape(&want["shape"]), "{file}:{path} shape"); let (got_kind, got) = data_strings(&a.data); assert_eq!(got_kind, kind, "{file}:{path} kind"); diff --git a/examples/wasm-viewer/test/make_fixture.py b/examples/wasm-viewer/test/make_fixture.py index c8d023a..8c7722c 100644 --- a/examples/wasm-viewer/test/make_fixture.py +++ b/examples/wasm-viewer/test/make_fixture.py @@ -175,10 +175,12 @@ def describe(path): walk(key.rstrip("/") + "/" + n, o) elif obj.dtype.names: expected["errors"][key] = "compound" - elif key == "/zstd": - expected["errors"][key] = "unsupported filter: 32015" else: expected["datasets"][key] = entry(obj, slab_for(obj)) + if key == "/zstd": + # Refused by the wasm build (no zstd); a native build + # that unifies in clawhdf5-format/zstd reads it. + expected["datasets"][key]["unavailable"] = "unsupported filter: 32015" walk("/", f) return expected diff --git a/examples/wasm-viewer/test/test.mjs b/examples/wasm-viewer/test/test.mjs index 1386f4c..80ca30a 100644 --- a/examples/wasm-viewer/test/test.mjs +++ b/examples/wasm-viewer/test/test.mjs @@ -69,6 +69,12 @@ for (const [name, exp] of Object.entries(expected)) { for (const [path, want] of Object.entries(exp.datasets)) { const ctx = `${name}:${path}`; eq(file.kind(path), "dataset", `${ctx} kind`); + if (want.unavailable) { + // The wasm build has no zstd (it links C): a clear error, no data. + assert.throws(() => file.read(path), (e) => e.message.includes(want.unavailable), ctx); + checks++; + continue; + } const info = file.info(path); eq([...info.shape, ...info.elementShape], want.shape, `${ctx} info shape`); const r = file.read(path);