diff --git a/.github/workflows/fixtures.yml b/.github/workflows/fixtures.yml index 7fb20de..b40ce9b 100644 --- a/.github/workflows/fixtures.yml +++ b/.github/workflows/fixtures.yml @@ -53,16 +53,14 @@ jobs: - name: Copy fixtures run: | - tests=(numbers strings lists records variants options many-arguments flavorful resources results lists-alias strings-alias strings-simple fixed-length-lists) - for test in "${tests[@]}"; do - # Find the composed artifact (filename varies per fixture) - src=$(find "/tmp/wit-bindgen/artifacts/${test}" -name 'composed-*.wasm' -print -quit 2>/dev/null) + # Copy all composed artifacts from wit-bindgen + for dir in /tmp/wit-bindgen/artifacts/*/; do + test=$(basename "$dir") + src=$(find "$dir" -name 'composed-*.wasm' -print -quit 2>/dev/null) dst="tests/wit_bindgen/fixtures/${test}.wasm" if [ -n "$src" ] && [ -f "$src" ]; then cp "$src" "$dst" echo "Copied ${test}.wasm (from $(basename "$src"))" - else - echo "::warning::Artifact not found for ${test}" fi done @@ -90,8 +88,7 @@ jobs: - wit-bindgen version: `v${{ env.WIT_BINDGEN_VERSION }}` - Generated via `wit-bindgen test --languages rust --artifacts` - Fixtures updated: - `numbers`, `strings`, `lists`, `records`, `variants`, `options`, `many-arguments`, `flavorful`, `resources`, `results`, `lists-alias`, `strings-alias`, `strings-simple`, `fixed-length-lists` + All composed fixtures from `wit-bindgen test --languages rust` are copied automatically. add-paths: tests/wit_bindgen/fixtures/*.wasm labels: ci delete-branch: true diff --git a/meld-core/tests/wit_bindgen_runtime.rs b/meld-core/tests/wit_bindgen_runtime.rs index 88ba6e2..0dd4088 100644 --- a/meld-core/tests/wit_bindgen_runtime.rs +++ b/meld-core/tests/wit_bindgen_runtime.rs @@ -588,3 +588,142 @@ fn test_runtime_wit_bindgen_resources() { .expect("resources: component fusion should succeed"); run_wasi_component(&fused).expect("resources: runtime execution should succeed"); } + +// --------------------------------------------------------------------------- +// New fixture tests (issue #1 coverage expansion) +// --------------------------------------------------------------------------- + +macro_rules! runtime_test { + ($name:ident, $fixture:expr) => { + #[test] + fn $name() { + if !fixture_exists($fixture) { + return; + } + let fused = fuse_fixture($fixture, OutputFormat::Component) + .expect(concat!($fixture, ": component fusion should succeed")); + run_wasi_component(&fused) + .expect(concat!($fixture, ": runtime execution should succeed")); + } + }; +} + +macro_rules! fuse_only_test { + ($name:ident, $fixture:expr) => { + #[test] + fn $name() { + if !fixture_exists($fixture) { + return; + } + fuse_fixture($fixture, OutputFormat::CoreModule) + .expect(concat!($fixture, ": core module fusion should succeed")); + } + }; +} + +// Resource fixtures — stress-test SR-25 borrow/own handle translation +runtime_test!(test_runtime_wit_bindgen_resource_borrow, "resource-borrow"); +runtime_test!( + test_runtime_wit_bindgen_resource_alias_redux, + "resource_alias_redux" +); +runtime_test!( + test_runtime_wit_bindgen_resource_into_inner, + "resource_into_inner" +); +runtime_test!( + test_runtime_wit_bindgen_owned_resource_deref_mut, + "owned-resource-deref-mut" +); +// with-and-resources: adapter codegen produces empty stack (same as resource_alias) +fuse_only_test!( + test_fuse_wit_bindgen_with_and_resources, + "with-and-resources" +); + +// Resource fixtures — known failures (graceful degradation) +// resource_alias: adapter codegen produces empty stack (type mismatch) +// resource_aggregates: own handle leak (handle != 0 assertion) +// resource_floats: borrow handle not converted in 3-component chain (align 8) +// resource_borrow_in_record: borrow inside record not detected as flat param +// resource_with_lists: data corruption in resource+list combination +// ownership: resource ownership transfer issue +// xcrate: resource handle lookup failure in 3-component chain +fuse_only_test!(test_fuse_wit_bindgen_resource_alias, "resource_alias"); +fuse_only_test!( + test_fuse_wit_bindgen_resource_aggregates, + "resource_aggregates" +); +fuse_only_test!(test_fuse_wit_bindgen_resource_floats, "resource_floats"); +fuse_only_test!( + test_fuse_wit_bindgen_resource_borrow_in_record, + "resource_borrow_in_record" +); +fuse_only_test!( + test_fuse_wit_bindgen_resource_with_lists, + "resource_with_lists" +); +fuse_only_test!(test_fuse_wit_bindgen_ownership, "ownership"); +fuse_only_test!(test_fuse_wit_bindgen_xcrate, "xcrate"); + +// resource-import-and-export: core fusion works, P2 wrapping fails on toplevel-import +fuse_only_test!( + test_fuse_wit_bindgen_resource_import_and_export, + "resource-import-and-export" +); + +// Type composition and misc fixtures +runtime_test!(test_runtime_wit_bindgen_demo, "demo"); +runtime_test!(test_runtime_wit_bindgen_gated_features, "gated-features"); +runtime_test!( + test_runtime_wit_bindgen_symbol_conflicts, + "symbol-conflicts" +); +runtime_test!(test_runtime_wit_bindgen_unused_types, "unused-types"); +runtime_test!( + test_runtime_wit_bindgen_package_with_version, + "package-with-version" +); + +// versions: wrong function dispatched across versioned interfaces +fuse_only_test!(test_fuse_wit_bindgen_versions, "versions"); + +// Rust binding-specific fixtures (still valid fusion targets) +runtime_test!( + test_runtime_wit_bindgen_alternative_bitflags, + "alternative-bitflags" +); +runtime_test!(test_runtime_wit_bindgen_custom_derives, "custom-derives"); +runtime_test!( + test_runtime_wit_bindgen_disable_custom_section, + "disable-custom-section-link-helpers" +); +runtime_test!( + test_runtime_wit_bindgen_other_dependencies, + "other-dependencies" +); +runtime_test!(test_runtime_wit_bindgen_raw_strings, "raw-strings"); +runtime_test!(test_runtime_wit_bindgen_skip, "skip"); +runtime_test!( + test_runtime_wit_bindgen_type_section_suffix, + "type_section_suffix" +); + +// with: P2 wrapper resource type encoding issue +fuse_only_test!(test_fuse_wit_bindgen_with, "with"); + +runtime_test!( + test_runtime_wit_bindgen_with_only_affects_imports, + "with-only-affects-imports" +); +runtime_test!( + test_runtime_wit_bindgen_with_option_generate, + "with-option-generate" +); +runtime_test!(test_runtime_wit_bindgen_with_types, "with-types"); + +// run-ctors-once-workaround: no `run` export (different entry point, not a meld issue) +fuse_only_test!( + test_fuse_wit_bindgen_run_ctors_once, + "run-ctors-once-workaround" +); diff --git a/tests/wit_bindgen/BUILD.bazel b/tests/wit_bindgen/BUILD.bazel index 38f2389..ebb22c5 100644 --- a/tests/wit_bindgen/BUILD.bazel +++ b/tests/wit_bindgen/BUILD.bazel @@ -39,6 +39,38 @@ WIT_BINDGEN_TESTS = [ "strings-alias", "strings-simple", "fixed-length-lists", + # New fixtures (issue #1 coverage expansion) + "alternative-bitflags", + "custom-derives", + "demo", + "disable-custom-section-link-helpers", + "gated-features", + "other-dependencies", + "owned-resource-deref-mut", + "ownership", + "package-with-version", + "raw-strings", + "resource-borrow", + "resource-import-and-export", + "resource_aggregates", + "resource_alias", + "resource_alias_redux", + "resource_borrow_in_record", + "resource_floats", + "resource_into_inner", + "resource_with_lists", + "run-ctors-once-workaround", + "skip", + "symbol-conflicts", + "type_section_suffix", + "unused-types", + "versions", + "with", + "with-and-resources", + "with-only-affects-imports", + "with-option-generate", + "with-types", + "xcrate", ] # Fuse composed component with meld diff --git a/tests/wit_bindgen/README.md b/tests/wit_bindgen/README.md index c772d6b..b4a5630 100644 --- a/tests/wit_bindgen/README.md +++ b/tests/wit_bindgen/README.md @@ -21,10 +21,11 @@ cargo install wit-bindgen-cli # Generate test artifacts wit-bindgen test --languages rust --artifacts artifacts tests/runtime -# Copy fixtures to meld -for test in numbers strings lists records variants options many-arguments flavorful resources results lists-alias strings-alias strings-simple fixed-length-lists; do - src=$(find "artifacts/${test}" -name 'composed-*.wasm' -print -quit) - cp "$src" "/path/to/meld/tests/wit_bindgen/fixtures/${test}.wasm" +# Copy all fixtures to meld +for dir in artifacts/*/; do + test=$(basename "$dir") + src=$(find "$dir" -name 'composed-*.wasm' -print -quit) + [ -n "$src" ] && cp "$src" "/path/to/meld/tests/wit_bindgen/fixtures/${test}.wasm" done ``` @@ -58,22 +59,12 @@ fixtures/{test}.wasm (composed component) ## Test Cases -| Test | Description | -|------|-------------| -| `numbers` | Integer and float type conversions | -| `strings` | String passing across component boundaries | -| `lists` | List/array handling | -| `records` | Struct-like composite types | -| `variants` | Variant, enum, option, result types | -| `options` | Option with string payloads, nested options | -| `many-arguments` | Functions with 16 parameters (spilling) | -| `flavorful` | Mixed types: lists in records/variants, typedefs | -| `resources` | Resource handle (own/borrow) pass-through across components | -| `results` | Result error handling patterns across boundaries | -| `lists-alias` | List types via type aliases (regression for layout bugs) | -| `strings-alias` | String types via type aliases | -| `strings-simple` | Minimal string passing baseline | -| `fixed-length-lists` | Fixed-length list types (bounded arrays) | +45 fixtures from the wit-bindgen test suite. 21 pass full runtime execution, +12 pass core fusion only (graceful degradation), and tests skip gracefully +when `.wasm` files are absent. + +See `meld-core/tests/wit_bindgen_runtime.rs` for the full test list and +per-fixture status notes. ## Notes