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- Suite `ets-es-checked` requires [node and some packages](#sts-es-checked-dependencies)
7
8## Quick run
9
10It is possible to run tests either using script `runner.sh` or `main.py` directly.
11
12### Shell script
13Script `runner.sh` activates the virtual environment with all required libraries
14installed by `scripts/install-deps-ubuntu -i=test` and then runs test(s).
15This way is preferable.
16
17After install script finishes you can run
18
19```bash
20export PROJECT=/path/to/panda
21export BUILD=/path/to/panda/build
22
23$PROJECT/tests/tests-u-runner/runner.sh <test-suite-name> --build-dir $BUILD
24```
25
26List of possible values for `<test-suite-name>` is below.
27
28### Python script
29You can run `main.py` directly. In order to do so you have to activate
30the virtual environment `$HOME/.venv-panda` manually or propose all required
31libraries in your working environment. Then `main.py` will run test(s) for you.
32
33```bash
34export PROJECT=/path/to/panda
35export BUILD=/path/to/panda/build
36
37python3 $PROJECT/tests/tests-u-runner/main.py <test-suite-name> --build-dir $BUILD
38```
39
40### Supported STS test suites
41
42- `--parser` - parser (aka regression)
43 Tests folders:
44 - `ets_frontend/ets2panda/test/parser/ets`
45 - `ets_frontend/ets2panda/test/compiler/ets`
46- `--ets-func-tests` - tests for ArkTS: standard library and sts func tests
47 Tests folder: `plugins/ets/tests/ets_func_tests/`
48 Chapters:
49 - `all`
50 - `algorithms-dir`
51 - `escompat-dir`
52 - `regression-dir`
53 - `spec-dir`
54 - `std-containers-dir`
55 - `std-core-dir`
56 - `std-math-dir`
57 - `std-time-dir`
58 - `chapter-1-of-4`
59 - `chapter-2-of-4`
60 - `chapter-3-of-4`
61 - `chapter-4-of-4`
62- `--ets-es-checked` - `STS tests that cross validate results with ts`
63 `--ets-gc-stress` - `GC stress tests`
64- `--ets-runtime` - `STS runtime tests`
65 Tests folder: `ets_frontend/ets2panda/test/runtime/ets`
66- `--ets-cts` - CTS language specification tests
67 Tests folder: `plugins/ets/tests/ets-templates`
68 Chapters:
69 - `all`
70 - `chapter02` - `02.lexical_elements`
71 - `chapter03` - `03.types`
72 - `chapter04` - `04.names_declarations_and_scopes`
73 - `chapter05` - `05.generics`
74 - `chapter06` - `06.contexts_and_conversions`
75 - `chapter07` - `07.expressions`
76 - `chapter08` - `08.statements`
77 - `chapter09` - `09.classes`
78 - `chapter10` - `10.interfaces`
79 - `chapter11` - `11.enumerations`
80 - `chapter12` - `12.errors_handling`
81 - `chapter13` - `13.modules_and_compilation_units`
82 - `chapter15` - `15.semantic_rules`
83 - `chapter17` - `17.experimental_features`
84 - `chapters02-05`
85 - `chapters06-09`
86 - `chapters10-12`
87 - `chapters13-17`
88
89### Supported JS test suites
90
91- `--parser` - parser (aka regression)
92- `--hermes` - Hermes JS runtime tests. To run tests from the Hermes suite, specify environment variables `HERMES_REVISION` and `HERMES_URL` in the `.env` file.
93- `--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.
94
95Additionally, a test suite can be specified with the option `--test-suite`: for example, for test262 `--test-suite test262`,
96for ets-func-tests `--test-suite ets_func_tests`
97
98### ArkTS important notes
99
100The full command for running all stdlib tests and ets_func_tests would be:
101
102`$PROJECT/tests/tests-u-runner/runner.sh --ets-func-tests --build-dir $BUILD`
103
104or
105
106`python3 $PROJECT/tests/tests-u-runner/main.py --ets-func-tests --build-dir $BUILD`
107
108ArkTS STDLIB tests are generated automatically from Jinja2 template. By default, runner starts test code generation automatically.
109As well test generator can be run as a standalone command, the corresponding procedure is described in plugins/ets/tests/stdlib-templates/readme.md
110
111## Reproducing CI test run
112
113In case of fail on CI runner will show its options - use it to run test locally.
114
115For example, to run the test262 test suite with AOT FULL INLINE the build options could be following:
116
117`$PROJECT/tests/tests-u-runner/runner.sh --test262 --gc-type=g1-gc --aot --aot-args='--compiler-inline-full-intrinsics=true' --aot-args='--compiler-memory-size-limit=4294967296' --build-dir $BUILD`
118
119## Yaml configuration files
120
121Any option can be set through yaml configuration file as `--config $YAML_CONFIG_FILE`. It can be mentioned several times
122and the data are merged according to following rules:
123- If some keys are repeated the latest value is taken (from the last specified config file)
124- If for a key different types are specified the first-met type is taken
125- If for a key different lists are specified they are merged and repeated values are excluded.
126
127The folder `cfg` contains several example config files which should be edited to set the real `$panda` and `$panda_build` paths,
128and any custom paths.
129
130To see full list of supported options use option `--generate-config $YAML_CONFIG_FILE`:
131
132`$PROJECT/tests/tests-u-runner/runner.sh --generate-config $YAML_CONFIG_FILE <test-suite-name> --build-dir $BUILD`
133
134The generated file will contain all supported options with default values.
135
136> **Note**: if an option is set both in yaml config file and in command line interface the latter value will
137> be applied. So cli value has a higher priority.
138
139## Important runner options
140
141Note: after `/` the option name from config file is specified.
142
143- `--build-dir`/`general.build` - the path to the compiled project. Referenced as $BUILD in this readme.
144- `--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
145- `--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.
146- `--work-dir`/`general.work-dir` - path to the working temp folder with gen, intermediate and report folders.
147where tests are generated from templates. For Hermes and Test262 it's a path where tests transformed for run are copied.
148
149## Test lists
150
151Runner supports following kinds of test lists:
152
153- **excluded** test lists - tests specified here are excluded from execution. "Don't try to run"
154- **ignored** test lists - tests specified here run, but failures are ignored. Such lists are named "known failures list" or KFL as well.
155
156Test list name usually has the following format: `<test-suite-name>[-<additional info>]-<kind>[-<OS>][-<architecture>][-<configuration>][-<sanitizer>][-<opt-level>][-REPEATS][-<build-type>].txt`
157
158- `kind` is one of `excluded` or `ignored`
159- `OS` is one of `LIN`, `WIN`, `MAC`. If an operating system is set explicitly, the test list is applied only to this OS. If none is set, the list is applied to any OS.
160- `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.
161- `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.
162- `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.
163- `opt-level` is `OLx`, where `x` is opt-level, usually 0 or 2.
164- `REPEATS` is set if the test list should apply to runs with the option `--jit-repeats` sets number of repeats more than 1.
165- `build-type` is one of `DEBUG`, `RELEASE`, `FAST-VERIFY`. If a build type is set explicitly, the test list is applied only to this build type. If none is set, the list is applied to any build type.
166
167Examples:
168
169- `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.
170- `hermes-excluded.txt` - list of excluded tests from Hermes suite, applied in any configuration.
171- `parser-js-ignored.txt` - list of ignored tests from JS Parser suite, applied in any configuration.
172- `ets-func-tests-ignored.txt` - list of ignored tests in `ets-func-tests` test suite
173- `ets-cts-FastVerify-ignored-OL2.txt` - list of ignored tests for `ets-cts` test suite and for opt-level=2. `FastVerify` is additional info.
174
175In any test list the test is specified as path to the test file relative from the `test_root`: Examples:
176
177- array-large.js
178- built-ins/Date/UTC/fp-evaluation-order.js
179- tests/stdlib/std/math/sqrt-negative-01.sts
180
181Test file specified in the option `--test-file` should be set in this format too.
182By default, ignored or excluded lists are located in correspondent project folder (for example for ArkTS should be `runtime_core/static_core/tests/tests-u-runner/test-lists`)
183
184All test lists are loaded automatically from the specified `LIST_ROOT` and based on following options:
185- architecture:
186 - from cli one of: `--test-list-arch=ARCH`, where ARCH is one of `amd64`, `arm32`, `arm64`
187 - from config file: `test-lists.architecture: ARCH`. Values are the same.
188- sanitizer:
189 - from cli on of: `--test-list-san=SAN`, where SAN in one of `asan` or `tsan`
190 - from config file: `test-lists.sanitizer: SAN`. Values are the same
191
192> **Note**: these options just specifies what test lists to load and do not affect on how and where to start the runner
193> itself and binaries used within.
194
195## Utility runner options:
196
197- `--skip-test-lists`/`test-lists.skip-test-lists: True` - do not use ignored or excluded lists, run all available tests, report all found failures
198- `--test-list TEST_LIST`/`test-lists.explicit-list: TEST_LIST` - run tests ONLY listed in TEST\_LIST file.
199- `--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.
200- `--update-excluded`/`test-lists.update-excluded: True` - regenerates excluded test lists
201- `--update-expected`/`test-lists.update-expected: True` - regenerates expected test lists (applied only for JS Parser test suite)
202- `--report-format`/`report.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.
203- `--filter FILTER`/`test-lists.filter: FILTER` - test filter regexp
204- `--show-progress`/`general.show-progress: True` - show progress bar during test execution
205- `--time-report`/`time-report.enable: True` - generates report with grouping tests by execution time.
206
207## Detailed report
208
209Detailed report shows test statistics for every folder
210- `--detailed-report`/`report.detailed-report: True` - if it's specified the report is generated
211- `--detailed-report-file FILE`/`report.detailed-report-file: FILE` - specifies file/path where the report should be saved to
212
213## ArkTS Specification coverage report
214
215ArkTS Specification coverage report shows test statistics for every specification chapter or section
216- `--spec-report`/`report.spec-report: True` - if it's specified the two report files are generated
217- `--spec-report-file FILE`/`report.spec-report-file: FILE` - specifies file/path to output the markdown-formatted report
218- `--spec-report-yaml FILE`/`report.spec-report-yaml: FILE` - specifies file/path to output the YAML-formatted report
219- `--spec-file FILE`/`report.spec-file: FILE` - specifies file/path to the specification PDF file
220
221## Verbose and logging options:
222
223- `--verbose`, `-v` - Enable verbose output. Possible values one of:
224 - `all` - the most detailed output,
225 - `short` - test status and output.
226 - if none specified (by default): only test status for new failed tests
227 - in config file use `general.verbose` property with the save values.
228- `--verbose-filter` - Filter for what kind of tests to output stdout and stderr.
229 Supported values:
230 - `all` - for all executed tests both passed and failed.
231 - `ignored` - for new failures and tests from ignored test lists including both passed and failed. '
232 - `new` - only for new failures. Default value.
233 - in config file use `general.verbose-filter` property with the same values.
234
235## Generation options:
236
237- `--generate-only`/`general.generate-only` - only generate tests without running them. Tests are run as usual without this option.
238- `--force-generate`/`ets.force-generate` - force STS tests generation from templates
239
240## Timeout options:
241
242All timeouts are set in seconds
243
244- `--es2panda-timeout`/`es2panda.timeout` - es2panda translator timeout
245- `--paoc-timeout`/`ark_aot.timeout` - paoc compiler timeout
246- `--timeout`/`ark.timeout` - ark runtime timeout
247
248## Configuration options:
249
250- `--aot`/`ark_aot.enable: True` - use AOT compilation
251- `--jit`/`ark.jit.enable` - use JIT in interpreter
252- `--interpreter-type`/`ark.interpreter-type` - use explicitly specified interpreter for es2panda. Popular values: `irtoc`, `llvm`, `cpp`.
253
254## JIT specific option
255- `--jit-preheat-repeats` - compound option to set additional parameters for JIT preheat actions.
256 Example how to set and supported values (they are default as well): `"num_repeats=30,compiler_threshold=20"`.
257 Works only with `--jit` options. If to use it with default values just set the empty string: `--jit-preheat-repeats=""`
258- in config file use `ark.jit.num_repeats` and `ark.jit.compiler_threshold` with explicit values.
259
260## Other options:
261
262To get runner all options use: `main.py --help` or `runner.sh --help`
263
264```
265 --no-run-gc-in-place enable --run-gc-in-place mode
266 --gc-type GC_TYPE Type of garbage collector
267 --heap-verifier Heap verifier options
268 --no-bco disable bytecodeopt
269 --arm64-compiler-skip
270 use skiplist for tests failing on aarch64 in AOT or JIT mode
271 --arm64-qemu launch all binaries in qemu aarch64
272 --arm32-qemu launch all binaries in qemu arm
273 --aot-args AOT_ARGS Additional arguments that will passed to ark_aot
274```
275
276## Execution time report
277
278It is possible to collect statistics how long separate tests work. In the result report tests are grouped by execution time.
279
280The 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.
281
282- Specify the option `--time-report`/`time-report.enable: True`
283- Specify the option `--time-edges TIME_EDGES` in the format "1 5 10"
284or in yaml config file `time-report.time-edges: [1, 5, 10]` in the list of integers format.
285- After test run the short report will be output to the console
286- And full report will be created at the `<report_root>/time_report.txt`
287
288
289## Linter and type checks
290
291A script running linter and type checks starts as:
292
293`$PROJECT/tests/tests-u-runner/linter.sh`
294
295It performs checks by running `pylint` and `mypy`.
296
297For `pylint` settings see `.pylintrc` file. For `mypy` settings see `mypy.ini` file.
298
299## STS ES checked dependencies
300- ruby (installed by default with `$PROJECT/scripts/install-deps-ubuntu -i=dev`)
301- node and ts-node, to install them see commands below
302
303```bash
304sudo apt-get -y install npm
305sudo npm install -g n
306sudo n install 21.4.0
307cd $PROJECT/tests/tests-u-runner/tools/generate-es-checked
308npm install
309```
310
311## Custom suite
312If you want to run arbitrary set of STS tests with URunner you can use a custom suite like (minimal configuration):
313
314`$PROJECT/tests/tests-u-runner/runner.sh $PROJECT --ets-custom --build-dir $BUILD --custom-suite SUITE_NAME --custom-test-root TEST_ROOT --custom-list-root LIST_ROOT`
315
316where:
317- SUITE_NAME - a tag used to name the suite
318- TEST_ROOT - a path to the folder with tests (*.sts files or templates)
319- LIST_ROOT - a path to the folder with ignored/excluded lists. Note: SUITE_NAME is used as a <test-suite-name> in the name of the test list (see #Test lists for details)
320
321In yaml configuration file these options can be specified as:
322```yaml
323 custom:
324 suite-name: SUITE_NAME
325 test-root: TEST_ROOT
326 list-root: LIST_ROOT
327```
328
329### Custom generator
330It is possible to specify a custom generator. It should be executable file accepting following parameters:
331
332`custom_generator --source SOURCE_PATH --target TARGET_PATH <other-options>`
333
334Here:
335- SOURCE_PATH - path where template files are located. URunner fills this parameter with TEST_ROOT specified above.
336- TARGET_PATH - path where generated tests should be put. URunner fills this parameter with value from --work-dir option ($WorkDir/gen)
337- other-options - other options that might be required by the generator (optional)
338
339To specify generator and its options use:
340- `--custom-generator PATH`/`custom.generator: PATH` - path to the executable file-generator
341- `--custom-generator-option`/`custom.generator-options: [OPTIONS]` - multiple value option (can be specified several times)
342