diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-01 09:46:31 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-02 16:09:16 +0430 |
commit | 7fb458b7c98e7c531e713c243da7c24e9fee182e (patch) | |
tree | b81b642b45c29eea97268b04da295c6092434c9a /Meta/generate-libwasm-spec-test.py | |
parent | fe026fef47cb35de605ba929e1b3ba2a437055cc (diff) | |
download | serenity-7fb458b7c98e7c531e713c243da7c24e9fee182e.zip |
Meta: Generate failing tests for unsupported assertions in wasm tests
Let's not ignore a test just because our test generator doesn't
understand it, assume the worst and generate a failing test case
instead.
Diffstat (limited to 'Meta/generate-libwasm-spec-test.py')
-rw-r--r-- | Meta/generate-libwasm-spec-test.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/Meta/generate-libwasm-spec-test.py b/Meta/generate-libwasm-spec-test.py index dc968bf323..8e0b63ea62 100644 --- a/Meta/generate-libwasm-spec-test.py +++ b/Meta/generate-libwasm-spec-test.py @@ -98,7 +98,19 @@ def generate(ast): "result": parse_typed_value(entry[2]) if len(entry) == 3 else None }) else: - print("Ignoring unknown assertion argument", entry[1][0], file=stderr) + if not len(tests): + tests.append({ + "module": "", + "tests": [] + }) + tests[-1]["tests"].append({ + "kind": "testgen_fail", + "function": { + "name": "<unknown>", + "args": [] + }, + "reason": f"Unknown assertion {entry[0][0][len('assert_'):]}" + }) elif len(entry) >= 2 and entry[0][0] == 'invoke': # toplevel invoke :shrug: tests[-1]["tests"].append({ @@ -110,7 +122,19 @@ def generate(ast): "result": parse_typed_value(entry[2]) if len(entry) == 3 else None }) else: - print("Ignoring unknown entry", entry, file=stderr) + if not len(tests): + tests.append({ + "module": "", + "tests": [] + }) + tests[-1]["tests"].append({ + "kind": "testgen_fail", + "function": { + "name": "<unknown>", + "args": [] + }, + "reason": f"Unknown command {entry[0][0]}" + }) return tests @@ -178,6 +202,9 @@ def genresult(ident, entry): if entry['kind'] == 'ignore': return f'module.invoke({ident}, {", ".join(genarg(x) for x in entry["function"]["args"])});\n ' + if entry['kind'] == 'testgen_fail': + return f'throw Exception("Test Generator Failure: " + {json.dumps(entry["reason"])});\n ' + return f'throw Exception("(Test Generator) Unknown test kind {entry["kind"]}");\n ' |