From a213981a473ab1f0b4c89e77ffc24c74c314fbe4 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 29 Mar 2026 23:05:28 +0100 Subject: [PATCH 1/2] Include `test/custom` test files --- update-testsuite.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/update-testsuite.py b/update-testsuite.py index 45e281f..c0c9ba9 100755 --- a/update-testsuite.py +++ b/update-testsuite.py @@ -118,7 +118,7 @@ def list_tests(self): This is used to run diffs and copy the test to its final location. """ tests = [] - for subdir in ['core', 'legacy']: + for subdir in ['core', 'legacy', 'custom']: for root, dirs, files in os.walk(f'repos/test/{subdir}'): for file in files: path = os.path.join(root, file) @@ -127,8 +127,8 @@ def list_tests(self): if ext != '.wast': continue dst = os.path.basename(path) - if subdir == 'legacy': - dst = 'legacy/' + dst + if subdir in ['legacy', 'custom']: + dst = subdir + '/' + dst tests.append((path, repo_path, dst)) return tests @@ -157,6 +157,7 @@ def main(): spec.checkout_merge() tests = [] for path, _repo_path, dst in spec.list_tests(): + os.makedirs(os.path.dirname(dst) or '.', exist_ok=True) shutil.copyfile(path, dst) tests.append(dst) git('add', *tests, quiet=True) From 89e9e936a94f925691cbc780b6a042f8cacad961 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 29 Mar 2026 23:09:55 +0100 Subject: [PATCH 2/2] Auto-update for 2026-03-29 Update repos: spec: https://github.com/WebAssembly/spec/commit/072bd0dc5c965120a111a67fa1849c0378f9a600 This change was automatically generated by `update-testsuite.py` --- custom/branch_hint.wast | 99 ++++++++++++++++++++++++++++++++++++++++ custom/custom_annot.wast | 99 ++++++++++++++++++++++++++++++++++++++++ custom/name_annot.wast | 38 +++++++++++++++ 3 files changed, 236 insertions(+) create mode 100644 custom/branch_hint.wast create mode 100644 custom/custom_annot.wast create mode 100644 custom/name_annot.wast diff --git a/custom/branch_hint.wast b/custom/branch_hint.wast new file mode 100644 index 0000000..f3c63b3 --- /dev/null +++ b/custom/branch_hint.wast @@ -0,0 +1,99 @@ +(module + (type (;0;) (func (param i32))) + (memory (;0;) 1 1) + (func $dummy) + (func $test1 (type 0) + (local i32) + local.get 1 + local.get 0 + i32.eq + (@metadata.code.branch_hint "\00" ) if + return + end + return + ) + (func $test2 (type 0) + (local i32) + local.get 1 + local.get 0 + i32.eq + (@metadata.code.branch_hint "\01" ) if + return + end + return + ) + (func (export "nested") (param i32 i32) (result i32) + (@metadata.code.branch_hint "\00") + (if (result i32) (local.get 0) + (then + (if (local.get 1) (then (call $dummy) (block) (nop))) + (if (local.get 1) (then) (else (call $dummy) (block) (nop))) + (@metadata.code.branch_hint "\01") + (if (result i32) (local.get 1) + (then (call $dummy) (i32.const 9)) + (else (call $dummy) (i32.const 10)) + ) + ) + (else + (if (local.get 1) (then (call $dummy) (block) (nop))) + (@metadata.code.branch_hint "\00") + (if (local.get 1) (then) (else (call $dummy) (block) (nop))) + (if (result i32) (local.get 1) + (then (call $dummy) (i32.const 10)) + (else (call $dummy) (i32.const 11)) + ) + ) + ) + ) +) + +(assert_malformed_custom + (module quote + "(func $test2 (type 0)" + " (local i32)" + " local.get 1" + " local.get 0" + " i32.eq" + " (@metadata.code.branch_hint \"\\01\" )" + " (@metadata.code.branch_hint \"\\01\" )" + " if" + " return" + " end" + " return" + ")" + ) + "@metadata.code.branch_hint annotation: duplicate annotation" +) +(assert_malformed_custom + (module quote + "(module" + " (@metadata.code.branch_hint \"\\01\" )" + " (type (;0;) (func (param i32)))" + " (memory (;0;) 1 1)" + " (func $test (type 0)" + " (local i32)" + " local.get 1" + " local.get 0" + " i32.eq" + " return" + " )" + ")" + ) + "@metadata.code.branch_hint annotation: not in a function" +) + +(assert_invalid_custom + (module + (type (;0;) (func (param i32))) + (memory (;0;) 1 1) + (func $test (type 0) + (local i32) + local.get 1 + local.get 0 + (@metadata.code.branch_hint "\01" ) + i32.eq + return + ) + ) + "@metadata.code.branch_hint annotation: invalid target" +) diff --git a/custom/custom_annot.wast b/custom/custom_annot.wast new file mode 100644 index 0000000..011a577 --- /dev/null +++ b/custom/custom_annot.wast @@ -0,0 +1,99 @@ +(module + (type $t (func)) + (@custom "my-section1" "contents-bytes1") + (@custom "my-section2" "more-contents-bytes0") + (@custom "my-section1" "contents-bytes2") + (@custom "my-section2" (before global) "more-contents-bytes1") + (@custom "my-section2" (after func) "more-contents-bytes2") + (@custom "my-section2" (after func) "more-contents-bytes3") + (@custom "my-section2" (before global) "more-contents-bytes4") + (func) + (@custom "my-section2" "more-contents-bytes5") + + (global $g i32 (i32.const 0)) + (@custom "my-section3") + (@custom "my-section4" "" "1" "" "2" "3" "") + (@custom "") +) + +(module quote "(@custom \"bla\")") +(module quote "(module (@custom \"bla\"))") + + +;; Malformed name + +(assert_malformed_custom + (module quote "(@custom)") + "@custom annotation: missing section name" +) + +(assert_malformed_custom + (module quote "(@custom 4)") + "@custom annotation: missing section name" +) + +(assert_malformed_custom + (module quote "(@custom bla)") + "@custom annotation: missing section name" +) + +(assert_malformed_custom + (module quote "(@custom \"\\df\")") + "@custom annotation: malformed UTF-8 encoding" +) + + +;; Malformed placement + +(assert_malformed_custom + (module quote "(@custom \"bla\" here)") + "@custom annotation: unexpected token" +) + +(assert_malformed_custom + (module quote "(@custom \"bla\" after)") + "@custom annotation: unexpected token" +) + +(assert_malformed_custom + (module quote "(@custom \"bla\" (after))") + "@custom annotation: malformed section kind" +) + +(assert_malformed_custom + (module quote "(@custom \"bla\" (type))") + "@custom annotation: malformed placement" +) + +(assert_malformed_custom + (module quote "(@custom \"bla\" (aft type))") + "@custom annotation: malformed placement" +) + +(assert_malformed_custom + (module quote "(@custom \"bla\" (before types))") + "@custom annotation: malformed section kind" +) + + +;; Misplaced + +(assert_malformed_custom + (module quote "(type (@custom \"bla\") $t (func))") + "misplaced @custom annotation" +) + +(assert_malformed_custom + (module quote "(func (@custom \"bla\"))") + "misplaced @custom annotation" +) + +(assert_malformed_custom + (module quote "(func (block (@custom \"bla\")))") + "misplaced @custom annotation" +) + +(assert_malformed_custom + (module quote "(func (nop (@custom \"bla\")))") + "misplaced @custom annotation" +) diff --git a/custom/name_annot.wast b/custom/name_annot.wast new file mode 100644 index 0000000..bf34fd6 --- /dev/null +++ b/custom/name_annot.wast @@ -0,0 +1,38 @@ +;; Module names + +(module (@name "Modül")) + +(module $moduel (@name "Modül")) + +(assert_malformed_custom + (module quote "(module (@name \"M1\") (@name \"M2\"))") + "@name annotation: multiple module" +) + +(assert_malformed_custom + (module quote "(module (func) (@name \"M\"))") + "misplaced @name annotation" +) + +(assert_malformed_custom + (module quote "(module (start $f (@name \"M\")) (func $f))") + "misplaced @name annotation" +) + + +;; Function names + +(module + (type $t (func)) + (func (@name "λ") (type $t)) + (func $lambda (@name "λ") (type $t)) +) + + +;; Tag names + +(module + (type $t (func)) + (tag (@name "θ") (type $t)) + (tag $theta (@name "θ") (type $t)) +)