From 714441c46dcc06937470e9a8cf5ed9855481f50d Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Fri, 18 Mar 2022 22:38:03 +0000 Subject: [PATCH] Add --generate-js-only flag to test runner This will return early right after generating JS from the wast test files. It will not attempt to run the tests, or do the round trip conversion from wasm <-> wast. This is convenient for proposals to add tests without having to update the reference interpreter with implementation, and generate those tests to JS to run in other Wasm engines. Fixes #1430. --- test/core/run.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/core/run.py b/test/core/run.py index cabb6188fe..a265c3284c 100755 --- a/test/core/run.py +++ b/test/core/run.py @@ -17,6 +17,7 @@ parser = argparse.ArgumentParser() parser.add_argument("--wasm", metavar="", default=os.path.join(os.getcwd(), "wasm")) parser.add_argument("--js", metavar="") +parser.add_argument("--generate-js-only", action='store_true') parser.add_argument("--out", metavar="", default=outputDir) parser.add_argument("file", nargs='*') arguments = parser.parse_args() @@ -29,6 +30,7 @@ wasmCommand = arguments.wasm jsCommand = arguments.js +generateJsOnly = arguments.generate_js_only outputDir = arguments.out inputFiles = arguments.file if arguments.file else main_test_files + simd_test_files + multi_memory_test_files @@ -65,6 +67,14 @@ def _runTestFile(self, inputPath): dir, inputFile = os.path.split(inputPath) outputPath = os.path.join(outputDir, inputFile) + # Generate JS first, then return early if we are only generating JS. + jsPath = self._auxFile(outputPath.replace(".wast", ".js")) + logPath = self._auxFile(jsPath + ".log") + self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, inputPath, jsPath), logPath) + + if generateJsOnly: + return + # Run original file expectedExitCode = 1 if ".fail." in inputFile else 0 logPath = self._auxFile(outputPath + ".log") @@ -97,9 +107,6 @@ def _runTestFile(self, inputPath): self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, wasm2Path, wast2Path), logPath) self._compareFile(wastPath, wast2Path) - jsPath = self._auxFile(outputPath.replace(".wast", ".js")) - logPath = self._auxFile(jsPath + ".log") - self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, inputPath, jsPath), logPath) if jsCommand != None: self._runCommand(('%s "%s"') % (jsCommand, jsPath), logPath)