readme.md
1# Universal test runner
2
3## Prerequisites
4- Panda build
5- Python3 with required libs (`tqdm`, `dataclasses`, `python-dotenv`, etc). Make sure that `scripts/install-deps-ubuntu` has run with option `-i=test`
6
7## Quick run
8
9It is possible to run tests either using script `runner.sh` or `main.py` directly.
10
11### Shell script
12Script `runner.sh` activates the virtual environment with all required libraries
13installed by `scripts/install-deps-ubuntu -i=test` and then runs test(s).
14This way is preferable.
15
16After install script finishes you can run
17
18```bash
19export PROJECT=/path/to/panda
20export BUILD=/path/to/panda/build
21
22$PROJECT/tests/tests-u-runner/runner.sh $PROJECT <test-suite-name> --build-dir $BUILD
23```
24
25List of possible values for `<test-suite-name>` is below.
26
27### Python script
28You can run `main.py` directly. In order to do so you have to activate
29the virtual environment `$HOME/.venv-panda` manually or propose all required
30libraries in your working environment. Then `main.py` will run test(s) for you.
31
32```bash
33export PROJECT=/path/to/panda
34export BUILD=/path/to/panda/build
35
36python3 $PROJECT/tests/tests-u-runner/main.py <test-suite-name> --build-dir $BUILD
37```
38
39### Supported test suites
40
41- `--parser` - parser (aka regression) tests
42- `--hermes` - Hermes JS runtime tests. To run tests from the Hermes suite, specify environment variables `HERMES_REVISION` and `HERMES_URL` in the `.env` file.
43- `--test262` - Test262 JS parser and runtime tests. To run tests from the test262 suite, specify environment variables `TEST262_REVISION` and `TEST262_URL` in the `.env` file.
44- `--ets-func-tests` - tests for ArkTS: standard library and ets func tests
45- `--ets-runtime` - ETS runtime tests
46- `--ets-cts` - CTS language specification tests
47
48Additionally, a test suite can be specified with the option `--test-suite`: for example, for test262 `--test-suite test262`,
49for ets-func-tests `--test-suite ets_func_tests`
50
51### ArkTS important notes
52
53The full command for running all stdlib tests and ets_func_tests would be:
54
55`$PROJECT/tests/tests-u-runner/runner.sh $PROJECT --ets-func-tests --build-dir $BUILD`
56
57or
58
59`python3 $PROJECT/tests/tests-u-runner/main.py --ets-func-tests --build-dir $BUILD`
60
61ArkTS STDLIB tests are generated automatically from Jinja2 template. By default, runner starts test code generation automatically.
62As well test generator can be run as a standalone command, the corresponding procedure is described in plugins/ets/tests/stdlib-templates/readme.md
63
64## Reproducing CI test run
65
66In case of fail on CI runner will show its options - use it to run test locally.
67
68For example, to run the test262 test suite with AOT FULL INLINE the build options could be following:
69
70`$PROJECT/tests/tests-u-runner/runner.sh $PROJECT --test262 --gc-type=g1-gc --aot --aot-args='--compiler-inline-full-intrinsics=true' --aot-args='--compiler-memory-size-limit=4294967296' --build-dir $BUILD`
71
72## Yaml configuration files
73
74Any option can be set through yaml configuration file as `--config $YAML_CONFIG_FILE`.
75The folder `cfg` contains several example config files which should be edited to set the real `$panda` and `$panda_build` paths,
76and any custom paths.
77tests/tests-u-runner/readme.md
78To see full list of supported options use option `--generate-config $YAML_CONFIG_FILE`:
79
80`$PROJECT/tests/tests-u-runner/runner.sh $PROJECT --generate-config $YAML_CONFIG_FILE <test-suite-name> --build-dir $BUILD`
81
82The generated file will contain all supported options with default values.
83
84> **Note**: if an option is set both in yaml config file and in command line interface the latter value will
85> be applied. So cli value has a higher priority.
86
87## Important runner options
88
89Note: after `/` the option name from config file is specified.
90
91- `--build-dir`/`general.build` - the path to the compiled project. Referenced as $BUILD in this readme.
92- `--test-root`/`general.test-root` - the folder where test suite is located. It must exist before runner starts. By default, Hermes and Test262 test suites are downloaded to `/tmp/<test-suite-name>` folder. Then they are unpacking, transforming and copying to `<panda-build>\<test-suite-name>` folder
93- `--list-root`/`general.list-root` - the folder where test lists are located. It must exist before runner starts. By default, it's the test suite plugin.
94- `--work-dir`/`general.work-dir` - path to the working temp folder with gen, intermediate and report folders.
95where tests are generated from templates. For Hermes and Test262 it's a path where tests transformed for run are copied.
96
97## Test lists
98
99Runner supports following kinds of test lists:
100
101- **excluded** test lists - tests specified here are excluded from execution. "Don't try to run"
102- **ignored** test lists - tests specified here run, but failures are ignored. Such lists are named "known failures list" or KFL as well.
103
104Test list name usually has the following format: `<test-suite-name>[-<additional info>]-<kind>[-<architecture>][-<configuration>][-<sanitizer>][-<opt-level>][-REPEATS].txt`
105
106- `kind` is one of `excluded` or `ignored`
107- `architecture` is one of `ARM32`, `ARM64`, `AMD32`, `AMD64`. If an architecture is set explicitly, the test list is applied only to this architecture. If none is set, the list is applied to any architecture.
108- `configuration` is one of `INT`, `AOT`, `AOT-FULL`, `IRTOC`, `LLVM`, `JIT` or other used value for `interpreter-type` option. If a configuration is set explicitly, the test list is applied only to this configuration. If none is set, the list is applied to any configuration.
109- `sanitizer` is one of `ASAN` or `TSAN`. If a sanitizer is set explicitly, the test list is applied only to this build configuration. If none is set, the list is applied to any configuration.
110- `opt-level` is `OLx`, where `x` is opt-level, usually 0 or 2.
111- `REPEATS` is set if the test list should apply to runs with the option `--jit-repeats` sets number of repeats more than 1.
112
113Examples:
114
115- `test262-flaky-ignored-JIT.txt` - list of ignored tests from Test262 suite, applied only in JIT configuration. `flaky` is additional info, it's only for more clear description what tests are collected there.
116- `hermes-excluded.txt` - list of excluded tests from Hermes suite, applied in any configuration.
117- `parser-js-ignored.txt` - list of ignored tests from JS Parser suite, applied in any configuration.
118- `ets-func-tests-ignored.txt` - list of ignored tests in `ets-func-tests` test suite
119- `ets-cts-FastVerify-ignored-OL2.txt` - list of ignored tests for `ets-cts` test suite and for opt-level=2. `FastVerify` is additional info.
120
121In any test list the test is specified as path to the test file relative from the `test_root`: Examples:
122
123- array-large.js
124- built-ins/Date/UTC/fp-evaluation-order.js
125- tests/stdlib/std/math/sqrt-negative-01.ets
126
127Test file specified in the option `--test-file` should be set in this format too.
128By default, ignored or excluded lists are located in corresponded runner plugin folder (for example for ArkTS should be `$PROJECT/tests/tests-u-runner/runner/plugins/ets`)
129
130All test lists are loaded automatically from the specified `LIST_ROOT` and based on following options:
131- architecture:
132 - from cli one of: `--test-list-arch=ARCH`, where ARCH is one of `amd64`, `arm32`, `arm64`
133 - from config file: `test-lists.architecture: ARCH`. Values are the same.
134- sanitizer:
135 - from cli on of: `--test-list-san=SAN`, where SAN in one of `asan` or `tsan`
136 - from config file: `test-lists.sanitizer: SAN`. Values are the same
137
138> **Note**: these options just specifies what test lists to load and do not affect on how and where to start the runner
139> itself and binaries used within.
140
141## Utility runner options:
142
143- `--skip-test-lists`/`test-lists.skip-test-lists: True` - do not use ignored or excluded lists, run all available tests, report all found failures
144- `--test-list TEST_LIST`/`test-lists.explicit-list: TEST_LIST` - run tests ONLY listed in TEST\_LIST file.
145- `--test-file TEST_FILE`/`test-lists.explicit-file: TEST_FILE` - run ONLY ONE specified test. **Attention** - not test suite, but the single test from the suite.
146- `--update-excluded`/`test-lists.update-excluded: True` - regenerates excluded test lists
147- `--update-expected`/`test-lists.update-expected: True` - regenerates expected test lists (applied only for JS Parser test suite)
148- `--report-format`/`general.report-format` - specifies in what format to generate failure reports. By default, `md`. Possible value: `html`. As well reports in the plain text format with `.log` extension are always generated.
149- `--filter FILTER`/`test-lists.filter: FILTER` - test filter regexp
150- `--show-progress`/`general.show-progress: True` - show progress bar during test execution
151- `--time-report`/`time-report.enable: True` - generates report with grouping tests by execution time.
152
153## Verbose and logging options:
154
155- `--verbose`, `-v` - Enable verbose output. Possible values one of:
156 - `all` - the most detailed output,
157 - `short` - test status and output.
158 - if none specified (by default): only test status for new failed tests
159 - in config file use `general.verbose` property with the save values.
160- `--verbose-filter` - Filter for what kind of tests to output stdout and stderr.
161 Supported values:
162 - `all` - for all executed tests both passed and failed.
163 - `ignored` - for new failures and tests from ignored test lists including both passed and failed. '
164 - `new` - only for new failures. Default value.
165 - in config file use `general.verbose-filter` property with the same values.
166
167## Generation options:
168
169- `--generate-only`/`general.generate-only` - only generate tests without running them. Tests are run as usual without this option.
170- `--force-generate`/`ets.force-generate` - force ETS tests generation from templates
171
172## Timeout options:
173
174All timeouts are set in seconds
175
176- `--es2panda-timeout`/`es2panda.timeout` - es2panda translator timeout
177- `--paoc-timeout`/`ark_aot.timeout` - paoc compiler timeout
178- `--timeout`/`ark.timeout` - ark runtime timeout
179
180## Configuration options:
181
182- `--aot`/`ark_aot.enable: True` - use AOT compilation
183- `--jit`/`ark.jit.enable` - use JIT in interpreter
184- `--interpreter-type`/`ark.interpreter-type` - use explicitly specified interpreter for es2panda. Popular values: `irtoc`, `llvm`, `cpp`.
185
186## JIT specific option
187- `--jit-preheat-repeats` - compound option to set additional parameters for JIT preheat actions.
188 Example how to set and supported values (they are default as well): `"num_repeats=30,compiler_threshold=20"`.
189 Works only with `--jit` options. If to use it with default values just set the empty string: `--jit-preheat-repeats=""`
190- in config file use `ark.jit.num_repeats` and `ark.jit.compiler_threshold` with explicit values.
191
192## Other options:
193
194To get runner all options use: `main.py --help` or `runner.sh $PROJECT --help`
195
196```
197 --no-run-gc-in-place enable --run-gc-in-place mode
198 --gc-type GC_TYPE Type of garbage collector
199 --heap-verifier Heap verifier options
200 --no-bco disable bytecodeopt
201 --arm64-compiler-skip
202 use skiplist for tests failing on aarch64 in AOT or JIT mode
203 --arm64-qemu launch all binaries in qemu aarch64
204 --arm32-qemu launch all binaries in qemu arm
205 --aot-args AOT_ARGS Additional arguments that will passed to ark_aot
206```
207
208## Execution time report
209
210It is possible to collect statistics how long separate tests work. In the result report tests are grouped by execution time.
211
212The grouping edges are set in seconds. For example, the value `1 5 10` specifies 4 groups - less than 1 second, from 1 second to 5 seconds, from 5 seconds to 10 seconds and from 10 seconds and more. For the last group the report contains real durations.
213
214- Specify the option `--time-report`/`time-report.enable: True`
215- Specify the option `--time-edges TIME_EDGES` in the format "1 5 10"
216or in yaml config file `time-report.time-edges: [1, 5, 10]` in the list of integers format.
217- After test run the short report will be output to the console
218- And full report will be created at the `<report_root>/time_report.txt`
219
220
221## Linter and type checks
222
223A script running linter and type checks starts as:
224
225`$PROJECT/tests/tests-u-runner/linter.sh $PROJECT`
226
227It performs checks by running `pylint` and `mypy`.
228
229For `pylint` settings see `.pylintrc` file. For `mypy` settings see `mypy.ini` file.
230