Skip to content

Commit 74a07f9

Browse files
committed
Run test262 JS conformance tests for QuickJS
Test262 are 70k+ Javascript conformance tests [1]. There is an upstream PR [2] to run these in CI there but until then can patch our own QuickJS and run them in our CI. One of the patches we have `04-test262-errors.patch` patches one of the exception we expect to get since modified the parser to accept the `function` expression syntax. [1] https://github.com/tc39/test262 [2] bellard/quickjs#408
1 parent 91bd2ed commit 74a07f9

File tree

10 files changed

+97
-3
lines changed

10 files changed

+97
-3
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ weatherreport-test: devclean escriptize
354354
@dev/run "$(TEST_OPTS)" -n 1 -a adm:pass --no-eval \
355355
'bin/weatherreport --etc dev/lib/node1/etc --level error'
356356

357+
.PHONY: quickjs-javascript-test
358+
# target: quickjs-javascript-tests - Run QuickJS JS conformance tests
359+
quickjs-javascript-test: couch
360+
@src/couch_quickjs/run_test262_tests.sh
361+
357362
################################################################################
358363
# Developing
359364
################################################################################

build-aux/Jenkinsfile.full

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ def generateContainerStage(platform) {
312312
dir( "${platform}/build" ) {
313313
sh "${configure(meta[platform])}"
314314
sh 'make'
315+
retry(1) {sh 'make quickjs-javascript-test'}
315316
retry(3) {sh 'make eunit'}
316317
retry(3) {sh 'make elixir'}
317318
retry(3) {sh 'make elixir-search'}

src/couch_quickjs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/quickjs/qjscalc.c
1717
/quickjs/repl.c
1818
/quickjs/run-test262
19+
/quickjs/test262_report.txt
20+
/quickjs/test262/
1921
/quickjs/test_fib.c
2022
/quickjs/.github
2123
compile_commands.json
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--- quickjs-master/Makefile 2025-05-29 14:01:24
2+
+++ quickjs/Makefile 2025-06-14 01:47:22
3+
@@ -53,6 +53,10 @@
4+
#CONFIG_MSAN=y
5+
# use UB sanitizer
6+
#CONFIG_UBSAN=y
7+
+
8+
+# TEST262 bootstrap config: commit id and shallow "since" parameter
9+
+TEST262_COMMIT?=3316c0aaf676d657f5a6b33364fa7e579c78ac7f
10+
+TEST262_SINCE?=2025-05-21
11+
12+
OBJDIR=.obj
13+
14+
@@ -464,6 +468,15 @@
15+
microbench: qjs$(EXE)
16+
$(WINE) ./qjs$(EXE) --std tests/microbench.js
17+
18+
+ifeq ($(wildcard test262/features.txt),)
19+
+test2-bootstrap:
20+
+ git clone --single-branch --shallow-since=$(TEST262_SINCE) https://github.com/tc39/test262.git
21+
+ (cd test262 && git checkout -q $(TEST262_COMMIT) && patch -p1 < ../tests/test262.patch && cd ..)
22+
+else
23+
+test2-bootstrap:
24+
+ (cd test262 && git fetch && git reset --hard $(TEST262_COMMIT) && patch -p1 < ../tests/test262.patch && cd ..)
25+
+endif
26+
+
27+
ifeq ($(wildcard test262o/tests.txt),)
28+
test2o test2o-update:
29+
@echo test262o tests not installed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- quickjs-master/tests/test262.patch 2025-05-29 14:01:24
2+
+++ quickjs/tests/test262.patch 2025-06-03 23:44:41
3+
@@ -14,9 +14,9 @@
4+
+// small: 200,
5+
+// long: 1000,
6+
+// huge: 10000,
7+
-+ yield: 20,
8+
-+ small: 20,
9+
-+ long: 100,
10+
++ yield: 40,
11+
++ small: 40,
12+
++ long: 200,
13+
+ huge: 1000,
14+
};
15+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- quickjs-master/test262_errors.txt 2025-05-29 14:01:24
2+
+++ quickjs/test262_errors.txt 2025-06-14 02:31:58
3+
@@ -1,6 +1,8 @@
4+
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: TypeError: ArrayBuffer is detached
5+
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: strict mode: TypeError: ArrayBuffer is detached
6+
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10: TypeError: $DONE() not called
7+
+test262/test/language/statements/expression/S12.4_A1.js:15: unexpected error type: Test262: This statement should not be evaluated.
8+
+test262/test/language/statements/expression/S12.4_A1.js:15: strict mode: unexpected error type: Test262: This statement should not be evaluated.
9+
test262/test/staging/sm/Date/UTC-convert-all-arguments.js:75: Test262Error: index 1: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
10+
test262/test/staging/sm/Date/constructor-convert-all-arguments.js:75: Test262Error: index undefined: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
11+
test262/test/staging/sm/Date/non-iso.js:76: Test262Error: Expected SameValue(«NaN», «-40071559730000») to be true

src/couch_quickjs/quickjs/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ PREFIX?=/usr/local
5454
# use UB sanitizer
5555
#CONFIG_UBSAN=y
5656

57+
# TEST262 bootstrap config: commit id and shallow "since" parameter
58+
TEST262_COMMIT?=3316c0aaf676d657f5a6b33364fa7e579c78ac7f
59+
TEST262_SINCE?=2025-05-21
60+
5761
OBJDIR=.obj
5862

5963
ifdef CONFIG_ASAN
@@ -464,6 +468,15 @@ stats: qjs$(EXE)
464468
microbench: qjs$(EXE)
465469
$(WINE) ./qjs$(EXE) --std tests/microbench.js
466470

471+
ifeq ($(wildcard test262/features.txt),)
472+
test2-bootstrap:
473+
git clone --single-branch --shallow-since=$(TEST262_SINCE) https://github.com/tc39/test262.git
474+
(cd test262 && git checkout -q $(TEST262_COMMIT) && patch -p1 < ../tests/test262.patch && cd ..)
475+
else
476+
test2-bootstrap:
477+
(cd test262 && git fetch && git reset --hard $(TEST262_COMMIT) && patch -p1 < ../tests/test262.patch && cd ..)
478+
endif
479+
467480
ifeq ($(wildcard test262o/tests.txt),)
468481
test2o test2o-update:
469482
@echo test262o tests not installed

src/couch_quickjs/quickjs/test262_errors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: TypeError: ArrayBuffer is detached
22
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34: strict mode: TypeError: ArrayBuffer is detached
33
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10: TypeError: $DONE() not called
4+
test262/test/language/statements/expression/S12.4_A1.js:15: unexpected error type: Test262: This statement should not be evaluated.
5+
test262/test/language/statements/expression/S12.4_A1.js:15: strict mode: unexpected error type: Test262: This statement should not be evaluated.
46
test262/test/staging/sm/Date/UTC-convert-all-arguments.js:75: Test262Error: index 1: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
57
test262/test/staging/sm/Date/constructor-convert-all-arguments.js:75: Test262Error: index undefined: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
68
test262/test/staging/sm/Date/non-iso.js:76: Test262Error: Expected SameValue(«NaN», «-40071559730000») to be true

src/couch_quickjs/quickjs/tests/test262.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ index 9828b15..4a5919d 100644
1414
+// small: 200,
1515
+// long: 1000,
1616
+// huge: 10000,
17-
+ yield: 20,
18-
+ small: 20,
19-
+ long: 100,
17+
+ yield: 40,
18+
+ small: 40,
19+
+ long: 200,
2020
+ huge: 1000,
2121
};
2222

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
DIR=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")
7+
8+
echo "+++++++++++++++++++++ Set up test262 repo +++++++++++++++++++++++"
9+
make -C ${DIR}/quickjs test2-bootstrap
10+
echo
11+
echo "++++++++++++++++++++++ Build test runner ++++++++++++++++++++++++"
12+
make -C ${DIR}/quickjs run-test262
13+
echo
14+
echo "++++++++++++++++++++++ Run test262 tests ++++++++++++++++++++++++"
15+
make -C ${DIR}/quickjs test2
16+
echo

0 commit comments

Comments
 (0)