| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
The test directory contains all tests, as well as scripts for running the tests.
All end-to-end tests are written using a text format that is parsed by test/run-tests.py. All files with the extension .txt recursively under the test directory will be run as tests.
The test runner itself is written in python and requires python 3.5 or above.
To run all the tests with default configuration:
$ make testEvery make target has a matching test-* target.
$ make gcc-debug-asan
$ make test-gcc-debug-asan
$ make clang-release
$ make test-clang-release
...You can also run the Python test runner script directly:
$ test/run-tests.pyTo run a subset of the tests, use a glob-like syntax:
$ test/run-tests.py const -v
+ dump/const.txt (0.002s)
+ parse/assert/bad-assertreturn-non-const.txt (0.003s)
+ parse/expr/bad-const-i32-overflow.txt (0.002s)
+ parse/expr/bad-const-f32-trailing.txt (0.004s)
+ parse/expr/bad-const-i32-garbage.txt (0.005s)
+ parse/expr/bad-const-i32-trailing.txt (0.003s)
+ parse/expr/bad-const-i32-underflow.txt (0.003s)
+ parse/expr/bad-const-i64-overflow.txt (0.002s)
+ parse/expr/bad-const-i32-just-negative-sign.txt (0.004s)
+ parse/expr/const.txt (0.002s)
[+10|-0|%100] (0.11s)
$ test/run-tests.py expr*const*i32 -v
+ parse/expr/bad-const-i32-just-negative-sign.txt (0.002s)
+ parse/expr/bad-const-i32-overflow.txt (0.003s)
+ parse/expr/bad-const-i32-underflow.txt (0.002s)
+ parse/expr/bad-const-i32-garbage.txt (0.004s)
+ parse/expr/bad-const-i32-trailing.txt (0.002s)
[+5|-0|%100] (0.11s)When tests are broken, they will give you the expected stdout/stderr as a diff:
$ <whoops, turned addition into subtraction in the interpreter>
$ test/run-tests.py interp/binary
- interp/binary.txt
STDOUT MISMATCH:
--- expected
+++ actual
@@ -1,4 +1,4 @@
-i32_add() => i32:3
+i32_add() => i32:4294967295
i32_sub() => i32:16
i32_mul() => i32:21
i32_div_s() => i32:4294967294
**** FAILED ******************************************************************
- interp/binary.txt
[+0|-1|%100] (0.13s)The test format is straightforward:
;;; KEY1: VALUE1A VALUE1B...
;;; KEY2: VALUE2A VALUE2B...
(input (to)
(the executable))
(;; STDOUT ;;;
expected stdout
;;; STDOUT ;;)
(;; STDERR ;;;
expected stderr
;;; STDERR ;;)The test runner will copy the input to a temporary file and pass it as an argument to the executable (which by default is out/wat2wasm).
The currently supported list of keys:
The currently supported list of tools (see run-tests.py):
Tests must be placed in the test/ directory, and must have the extension .txt. The subdirectory structure is mostly for convenience, so for example you can type test/run-tests.py interp to run all the interpreter tests. There's otherwise no logic attached to a test being in a given directory.
Here is a brief description of the tests are contained in each top-level subdirectory:
Try to make the test names self explanatory, and try to test only one thing. Also make sure that tests that are expected to fail start with bad-.
When you first write a test, it's easiest if you omit the expected stdout and stderr. You can have the test harness fill it in for you automatically. First let's write our test:
$ cat > test/my-awesome-test.txt << HERE
;;; TOOL: run-interp-spec
(module
(export "add2" 0)
(func (param i32) (result i32)
(i32.add (local.get 0) (i32.const 2))))
(assert_return (invoke "add2" (i32.const 4)) (i32.const 6))
(assert_return (invoke "add2" (i32.const -2)) (i32.const 0))
HEREIf we run it, it will fail:
- my-awesome-test.txt STDOUT MISMATCH: --- expected +++ actual @@ -0,0 +1 @@ +2/2 tests passed. **** FAILED ****************************************************************** - my-awesome-test.txt [+0|-1|%100] (0.03s)
We can rebase it automatically with the -r flag. Running the test again shows that the expected stdout has been added:
$ test/run-tests.py my-awesome-test -r
[+1|-0|%100] (0.03s)
$ test/run-tests.py my-awesome-test
[+1|-0|%100] (0.03s)
$ tail -n 3 test/my-awesome-test.txt
(;; STDOUT ;;;
2/2 tests passed.
;;; STDOUT ;;)| Back | FazBrowse Home | New Git URL |