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>][-<debug-info>][-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- `debug-info` is `DI` when `--es2panda-debug-info` option is specified. 165- `REPEATS` is set if the test list should apply to runs with the option `--jit-repeats` sets number of repeats more than 1. 166- `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. 167 168Examples: 169 170- `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. 171- `hermes-excluded.txt` - list of excluded tests from Hermes suite, applied in any configuration. 172- `parser-js-ignored.txt` - list of ignored tests from JS Parser suite, applied in any configuration. 173- `ets-func-tests-ignored.txt` - list of ignored tests in `ets-func-tests` test suite 174- `ets-cts-FastVerify-ignored-OL2.txt` - list of ignored tests for `ets-cts` test suite and for opt-level=2. `FastVerify` is additional info. 175 176In any test list the test is specified as path to the test file relative from the `test_root`: Examples: 177 178- array-large.js 179- built-ins/Date/UTC/fp-evaluation-order.js 180- tests/stdlib/std/math/sqrt-negative-01.sts 181 182Test file specified in the option `--test-file` should be set in this format too. 183By 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`) 184 185All test lists are loaded automatically from the specified `LIST_ROOT` and based on following options: 186- architecture: 187 - from cli one of: `--test-list-arch=ARCH`, where ARCH is one of `amd64`, `arm32`, `arm64` 188 - from config file: `test-lists.architecture: ARCH`. Values are the same. 189- sanitizer: 190 - from cli on of: `--test-list-san=SAN`, where SAN in one of `asan` or `tsan` 191 - from config file: `test-lists.sanitizer: SAN`. Values are the same 192 193> **Note**: these options just specifies what test lists to load and do not affect on how and where to start the runner 194> itself and binaries used within. 195 196## Utility runner options: 197 198- `--skip-test-lists`/`test-lists.skip-test-lists: True` - do not use ignored or excluded lists, run all available tests, report all found failures 199- `--test-list TEST_LIST`/`test-lists.explicit-list: TEST_LIST` - run tests ONLY listed in TEST\_LIST file. 200- `--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. 201- `--update-excluded`/`test-lists.update-excluded: True` - regenerates excluded test lists 202- `--update-expected`/`test-lists.update-expected: True` - regenerates expected test lists (applied only for JS Parser test suite) 203- `--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. 204- `--filter FILTER`/`test-lists.filter: FILTER` - test filter regexp 205- `--show-progress`/`general.show-progress: True` - show progress bar during test execution 206- `--time-report`/`time-report.enable: True` - generates report with grouping tests by execution time. 207 208## Detailed report 209 210Detailed report shows test statistics for every folder 211- `--detailed-report`/`report.detailed-report: True` - if it's specified the report is generated 212- `--detailed-report-file FILE`/`report.detailed-report-file: FILE` - specifies file/path where the report should be saved to 213 214## ArkTS Specification coverage report 215 216ArkTS Specification coverage report shows test statistics for every specification chapter or section 217- `--spec-report`/`report.spec-report: True` - if it's specified the two report files are generated 218- `--spec-report-file FILE`/`report.spec-report-file: FILE` - specifies file/path to output the markdown-formatted report 219- `--spec-report-yaml FILE`/`report.spec-report-yaml: FILE` - specifies file/path to output the YAML-formatted report 220- `--spec-file FILE`/`report.spec-file: FILE` - specifies file/path to the specification PDF file 221 222## Verbose and logging options: 223 224- `--verbose`, `-v` - Enable verbose output. Possible values one of: 225 - `all` - the most detailed output, 226 - `short` - test status and output. 227 - if none specified (by default): only test status for new failed tests 228 - in config file use `general.verbose` property with the save values. 229- `--verbose-filter` - Filter for what kind of tests to output stdout and stderr. 230 Supported values: 231 - `all` - for all executed tests both passed and failed. 232 - `ignored` - for new failures and tests from ignored test lists including both passed and failed. ' 233 - `new` - only for new failures. Default value. 234 - in config file use `general.verbose-filter` property with the same values. 235 236## Generation options: 237 238- `--generate-only`/`general.generate-only` - only generate tests without running them. Tests are run as usual without this option. 239- `--force-generate`/`ets.force-generate` - force STS tests generation from templates 240 241## Timeout options: 242 243All timeouts are set in seconds 244 245- `--es2panda-timeout`/`es2panda.timeout` - es2panda translator timeout 246- `--paoc-timeout`/`ark_aot.timeout` - paoc compiler timeout 247- `--timeout`/`ark.timeout` - ark runtime timeout 248 249## Configuration options: 250 251- `--aot`/`ark_aot.enable: True` - use AOT compilation 252- `--jit`/`ark.jit.enable` - use JIT in interpreter 253- `--interpreter-type`/`ark.interpreter-type` - use explicitly specified interpreter for es2panda. Popular values: `irtoc`, `llvm`, `cpp`. 254 255## JIT specific option 256- `--jit-preheat-repeats` - compound option to set additional parameters for JIT preheat actions. 257 Example how to set and supported values (they are default as well): `"num_repeats=30,compiler_threshold=20"`. 258 Works only with `--jit` options. If to use it with default values just set the empty string: `--jit-preheat-repeats=""` 259- in config file use `ark.jit.num_repeats` and `ark.jit.compiler_threshold` with explicit values. 260 261## Other options: 262 263To get runner all options use: `main.py --help` or `runner.sh --help` 264 265``` 266 --no-run-gc-in-place enable --run-gc-in-place mode 267 --gc-type GC_TYPE Type of garbage collector 268 --heap-verifier Heap verifier options 269 --no-bco disable bytecodeopt 270 --arm64-compiler-skip 271 use skiplist for tests failing on aarch64 in AOT or JIT mode 272 --arm64-qemu launch all binaries in qemu aarch64 273 --arm32-qemu launch all binaries in qemu arm 274 --aot-args AOT_ARGS Additional arguments that will passed to ark_aot 275``` 276 277## Execution time report 278 279It is possible to collect statistics how long separate tests work. In the result report tests are grouped by execution time. 280 281The 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. 282 283- Specify the option `--time-report`/`time-report.enable: True` 284- Specify the option `--time-edges TIME_EDGES` in the format "1 5 10" 285or in yaml config file `time-report.time-edges: [1, 5, 10]` in the list of integers format. 286- After test run the short report will be output to the console 287- And full report will be created at the `<report_root>/time_report.txt` 288 289 290## Linter and type checks 291 292A script running linter and type checks starts as: 293 294`$PROJECT/tests/tests-u-runner/linter.sh` 295 296It performs checks by running `pylint` and `mypy`. 297 298For `pylint` settings see `.pylintrc` file. For `mypy` settings see `mypy.ini` file. 299 300## STS ES checked dependencies 301- ruby (installed by default with `$PROJECT/scripts/install-deps-ubuntu -i=dev`) 302- node and ts-node, to install them see commands below 303 304```bash 305sudo apt-get -y install npm 306sudo npm install -g n 307sudo n install 21.4.0 308cd $PROJECT/tests/tests-u-runner/tools/generate-es-checked 309npm install 310``` 311 312## Custom suite 313If you want to run arbitrary set of STS tests with URunner you can use a custom suite like (minimal configuration): 314 315`$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` 316 317where: 318- SUITE_NAME - a tag used to name the suite 319- TEST_ROOT - a path to the folder with tests (*.sts files or templates) 320- 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) 321 322In yaml configuration file these options can be specified as: 323```yaml 324 custom: 325 suite-name: SUITE_NAME 326 test-root: TEST_ROOT 327 list-root: LIST_ROOT 328``` 329 330### Custom generator 331It is possible to specify a custom generator. It should be executable file accepting following parameters: 332 333`custom_generator --source SOURCE_PATH --target TARGET_PATH <other-options>` 334 335Here: 336- SOURCE_PATH - path where template files are located. URunner fills this parameter with TEST_ROOT specified above. 337- TARGET_PATH - path where generated tests should be put. URunner fills this parameter with value from --work-dir option ($WorkDir/gen) 338- other-options - other options that might be required by the generator (optional) 339 340To specify generator and its options use: 341- `--custom-generator PATH`/`custom.generator: PATH` - path to the executable file-generator 342- `--custom-generator-option`/`custom.generator-options: [OPTIONS]` - multiple value option (can be specified several times) 343