• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## File overview:
2```
3es5_tests.txt:  This file contains a list of ES5 test cases. If useful cases are found missing, you can add them as needed.
4es2015_tests.txt:  This file contains a full list of use cases of ES2015 except those filtered out with'es6id'. If useful cases are found missing, you can add them as needed.
5skip_tests.json: This file contains a list of use cases that do not meet the requirements. If useful cases are found missing, you can add them according to the specified format.
6```
7
8## 1. Compile ts2abc and ark_js_vm project
9```
10./build.sh --product-name Hi3516DV300 --build-target ark_js_vm --build-target ark_ts2abc_build
11```
12
13## 2 Run test cases
14
15### 2.1 Options
16```
17usage: run_test262.py [-h] [--dir DIR] [--file FILE] [--mode [{1,2,3}]]
18                      [--es51] [--es2015 [{all,only}]] [--esnext]
19                      [--engine FILE] [--babel] [--timeout TIMEOUT]
20                      [--threads THREADS] [--hostArgs HOSTARGS]
21                      [--ark-tool ARK_TOOL]
22                      [--ark-frontend-tool ARK_FRONTEND_TOOL]
23                      [--libs-dir LIBS_DIR]
24                      [--ark-frontend [{ts2panda,es2panda}]]
25
26optional arguments:
27  -h, --help            Show this help message and exit
28  --dir DIR             Directory to test
29  --file FILE           File to test
30  --mode [{1,2,3}]      selection information as: 1: only default 2:
31                        only strict mode 3: both default and strict mode
32  --es51                Run test262 ES5.1 version
33  --es2015 [{all,only}]
34                        Run test262 - ES2015. all: Contains all use cases for
35                        ES5 and ES2015, only: Only include use cases for
36                        ES2015
37  --esnext              Run test262 - ES.next.
38  --engine FILE         Other engine binarys to run tests with
39                        (as:d8,hermes,jsc,qjs...)
40  --babel               Whether to use Babel conversion
41  --timeout TIMEOUT     Set a custom test timeout in milliseconds !!!
42  --threads THREADS     Run this many tests in parallel. Note that the browser
43                        runners don't work great with t > 1.
44  --hostArgs HOSTARGS   command-line arguments to pass to eshost host
45  --ark-tool ARK_TOOL   ark's binary tool
46  --ark-frontend-tool ARK_FRONTEND_TOOL
47                        ark frontend conversion tool
48  --libs-dir LIBS_DIR   The path collection of dependent so, divided by':'
49  --ark-frontend [{ts2panda,es2panda}]
50                        Choose one of them
51```
52
53### 2.2 Run all the test cases
54
55```
56python3 test262/run_test262.py
57```
58
59### 2.3 Run `es51` related test cases
60
61```python
62python3 test262/run_test262.py --es51
63```
64
65After the execution finished, a directory named `test_es51` is created under directory `test262/data` , which is used to store all `es51` cases.
66
67### 2.4 Run `es2015` related test cases
68#### 2.4.1 only include use cases for ES2015
69```python
70python3 test262/run_test262.py --es2015 only
71```
72#### 2.4.2  Contains all use cases for ES5 and ES2015
73```python
74python3 test262/run_test262.py --es2015 all
75```
76
77### 2.5 Run single test case
78
79```python
80python3 test262/run_test262.py --file test262/data/test_es5/language/statements/break/12.8-1.js
81```
82
83### 2.6 Run all the test cases under specified directory
84
85```python
86python3 test262/run_test262.py --dir test262/data/test_es5/language/statements
87```
88
89### 2.7 Run single test case with other engines. Take d8 as an example
90
91```python
92 python3 test262/run_test262.py --engine="/home/share/v8-code/v8/out.gn/x64.release/d8" --file test262/data/test_es5/language/statements/break/12.8-1.js
93```
94### 2.8 Run single test case with `babel` conversion
95```
96python3 test262/run_test262.py  --babel --file test262/data/test_es5/language/statements/break/12.8-1.js
97```
98
99### 2.9 Get test result
100
101take the following code as an example:
102
103```shell
104zgy@lfgphicprd23154:/home/share/OpenHarmony2.0_20210604/ark/ts2abc$ python3 -B test262/run_test262.py --file test262/data/test_es51/language/statements/break/12.8-1.js
105
106Wait a moment..........
107
10807-30 16:56:03.857383 D:>>>       command: npm install | dir: /home/share/OpenHarmony2.0_20210604/out/ohos-arm-release/clang_x64/ark/ark/build/src/..
109npm WARN ts2panda@1.0.0 No description
110npm WARN ts2panda@1.0.0 No repository field.
111npm WARN ts2panda@1.0.0 No license field.
112npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
113npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
114
115up to date in 2.225s
116
11728 packages are looking for funding
118  run `npm fund` for details
119
12007-30 16:56:06.746184 D:>>>       command: npm install | dir: test262/eshost
121up to date in 1.446s
122
1231 package is looking for funding
124  run `npm fund` for details
125
12607-30 16:56:08.767037 D:>>>       command: npm install | dir: test262/harness
127up to date in 2.412s
12807-30 16:56:11.836409 D:>>>       command: git checkout -- . | dir: test262/data
12907-30 16:56:12.012115 D:>>>       command: git checkout 9ca13b12728b7e0089c7eb03fa2bd17f8abe297f | dir: test262/data
130HEAD is now at 9ca13b1272 Fix typo in BigIntArray property descriptor test
13107-30 16:56:12.275768 D:>>>       command: git checkout -- . | dir: test262/eshost
13207-30 16:56:12.280134 D:>>>       command: git apply ../eshost.patch | dir: test262/eshost
13307-30 16:56:12.283263 D:>>>       command: git checkout -- . | dir: test262/harness
13407-30 16:56:12.288134 D:>>>       command: git apply ../harness.patch | dir: test262/harness
135Test command:
136        node
137        test262/harness/bin/run.js
138        --hostType=panda
139        --hostPath=python3
140        --hostArgs='-B test262/run_sunspider.py --ark-tool=/home/share/OpenHarmony2.0_20210604/out/ohos-arm-release/clang_x64/ark/ark/ark_js_vm --ark-frontend-tool=/home/share/OpenHarmony2.0_20210604/out/ohos-arm-release/clang_x64/ark/ark/build/src/index.js --libs-dir=/home/share/OpenHarmony2.0_20210604/out/ohos-arm-release/clang_x64/ark/ark:/home/share/OpenHarmony2.0_20210604/out/ohos-arm-release/clang_x64/global/i18n_standard:/home/share/OpenHarmony2.0_20210604/prebuilts/clang/ohos/linux-x86_64/llvm/lib/ --ark-frontend=ts2panda '
141        --threads=15
142        --mode=only strict mode
143        --timeout=60000
144        --tempDir=out/test262
145        --test262Dir=test262/data
146        --saveCompiledTests
147        test262/data/test_es51/language/statements/break/12.8-1.js
148
149FAIL test262/data/test_es51/language/statements/break/12.8-1.js (strict mode)
150
151Ran 1 tests
1520 passed
1531 failed
154used time is: 0:00:13.303865
155```
156
157* `default` indicates `non-strict` mode; `strict mode` indicates the strict mode.
158
159* After the execution finished, the following files are generated under directory `out/test262/` (you can specified it in `test262/config.py`):
160
161```
162-rw-rw-r-- 1 zgy zgy 7583 Nov 21 18:18 12.8-1-default.abc
163-rw-rw-r-- 1 zgy zgy 415 Nov 21 18:18 12.8-1.js.panda.default.err
164-rw-rw-r-- 1 zgy zgy 4389 Nov 21 18:18 12.8-1.js.panda.default.fail
165-rw-rw-r-- 1 zgy zgy 415 Nov 21 18:18 12.8-1.js.panda.strict.err
166-rw-rw-r-- 1 zgy zgy 4403 Nov 21 18:18 12.8-1.js.panda.strict.fail
167-rw-rw-r-- 1 zgy zgy 7601 Nov 21 18:18 12.8-1-strict.abc
168```
169
170`.abc` indicates the generated binary `abc` file.
171
172`.err` indicates that an error occurred during the test.
173
174`.fail/.pass` is the file saved after `js` file has been preprocessed.
175
176The `result.txt` file is generated under directory `out/test262` to save statistics after the test finished.
177