summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshley Nelson <nashley@google.com>2022-05-31 14:20:06 -0700
committerGitHub <noreply@github.com>2022-05-31 21:20:06 +0000
commitc4988562f9ed04400fc348bf99d5709cf063d96e (patch)
tree3bb114aa556fbf6fdff8c1c5c08f77f15c545d1d
parent4d0646a6ea6d0104d8a5997f1d607d91e0a661a2 (diff)
downloadbinaryen-c4988562f9ed04400fc348bf99d5709cf063d96e.tar.gz
binaryen-c4988562f9ed04400fc348bf99d5709cf063d96e.tar.bz2
binaryen-c4988562f9ed04400fc348bf99d5709cf063d96e.zip
Updating spec test readme (#4706)
* Updating command to run spec tests * Delete run.py
-rw-r--r--test/spec/README.md10
-rwxr-xr-xtest/spec/run.py109
2 files changed, 6 insertions, 113 deletions
diff --git a/test/spec/README.md b/test/spec/README.md
index 319151461..f9f5ecbbc 100644
--- a/test/spec/README.md
+++ b/test/spec/README.md
@@ -2,10 +2,12 @@ This directory contains tests for the core WebAssembly semantics, as described i
Tests are written in the [S-Expression script format](https://github.com/WebAssembly/spec/blob/master/interpreter/README.md#s-expression-syntax) defined by the interpreter.
-The test suite can be run with the spec interpreter as follows:
+To execute all spec tests, run the following command from the binaryen top-level directory:
```
-./run.py --wasm <path-to-wasm-interpreter>
+./check.py spec
```
-where the path points to the spec interpreter executable (or a tool that understands similar options). If the binary is in the working directory, this option can be omitted.
-In addition, the option `--js <path-to-js-interpreter>` can be given to point to a stand-alone JavaScript interpreter supporting the WebAssembly API. If provided, all tests are also executed in JavaScript.
+Individual spec tests may be executed by running the following command from the binaryen top-level directory:
+```
+bin/wasm-shell [path to spec test]
+```
diff --git a/test/spec/run.py b/test/spec/run.py
deleted file mode 100755
index ec07929c4..000000000
--- a/test/spec/run.py
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/env python3
-
-from __future__ import print_function
-import argparse
-import os
-import os.path
-import unittest
-import subprocess
-import glob
-import sys
-
-
-ownDir = os.path.dirname(os.path.abspath(sys.argv[0]))
-inputDir = ownDir
-outputDir = os.path.join(inputDir, "_output")
-
-parser = argparse.ArgumentParser()
-parser.add_argument("--wasm", metavar="<wasm-command>", default=os.path.join(os.getcwd(), "wasm"))
-parser.add_argument("--js", metavar="<js-command>")
-parser.add_argument("--out", metavar="<out-dir>", default=outputDir)
-parser.add_argument("file", nargs='*')
-arguments = parser.parse_args()
-sys.argv = sys.argv[:1]
-
-wasmCommand = arguments.wasm
-jsCommand = arguments.js
-outputDir = arguments.out
-inputFiles = arguments.file if arguments.file else glob.glob(os.path.join(inputDir, "*.wast"))
-
-if not os.path.exists(wasmCommand):
- sys.stderr.write("""\
-Error: The executable '%s' does not exist.
-Provide the correct path with the '--wasm' flag.
-
-""" % (wasmCommand))
- parser.print_help()
- sys.exit(1)
-
-
-class RunTests(unittest.TestCase):
- def _runCommand(self, command, logPath, expectedExitCode = 0):
- with open(logPath, 'w+') as out:
- exitCode = subprocess.call(command, shell=True, stdout=out, stderr=subprocess.STDOUT)
- self.assertEqual(expectedExitCode, exitCode, "failed with exit code %i (expected %i) for %s" % (exitCode, expectedExitCode, command))
-
- def _auxFile(self, path):
- if os.path.exists(path):
- os.remove(path)
- return path
-
- def _compareFile(self, expectFile, actualFile):
- if os.path.exists(expectFile):
- with open(expectFile) as expect:
- with open(actualFile) as actual:
- expectText = expect.read()
- actualText = actual.read()
- self.assertEqual(expectText, actualText)
-
- def _runTestFile(self, inputPath):
- dir, inputFile = os.path.split(inputPath)
- outputPath = os.path.join(outputDir, inputFile)
-
- # Run original file
- expectedExitCode = 1 if ".fail." in inputFile else 0
- logPath = self._auxFile(outputPath + ".log")
- self._runCommand(('%s "%s"') % (wasmCommand, inputPath), logPath, expectedExitCode)
-
- if expectedExitCode != 0:
- return
-
- # Convert to binary and run again
- wasmPath = self._auxFile(outputPath + ".bin.wast")
- logPath = self._auxFile(wasmPath + ".log")
- self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, inputPath, wasmPath), logPath)
- self._runCommand(('%s "%s"') % (wasmCommand, wasmPath), logPath)
-
- # Convert back to text and run again
- wastPath = self._auxFile(wasmPath + ".wast")
- logPath = self._auxFile(wastPath + ".log")
- self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, wasmPath, wastPath), logPath)
- self._runCommand(('%s "%s"') % (wasmCommand, wastPath), logPath)
-
- # Convert back to binary once more and compare
- wasm2Path = self._auxFile(wastPath + ".bin.wast")
- logPath = self._auxFile(wasm2Path + ".log")
- self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, wastPath, wasm2Path), logPath)
- self._compareFile(wasmPath, wasm2Path)
-
- # Convert back to text once more and compare
- wast2Path = self._auxFile(wasm2Path + ".wast")
- logPath = self._auxFile(wast2Path + ".log")
- self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, wasm2Path, wast2Path), logPath)
- self._compareFile(wastPath, wast2Path)
-
- # Convert to JavaScript
- 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)
-
-
-if __name__ == "__main__":
- if not os.path.exists(outputDir):
- os.makedirs(outputDir)
- for fileName in inputFiles:
- testName = 'test ' + os.path.basename(fileName)
- setattr(RunTests, testName, lambda self, file=fileName: self._runTestFile(file))
- unittest.main()