Skip to content

Commit 9308ded

Browse files
committed
Add test262 setup patches to QuickJS
Test262 are 70k+ Javascript conformance tests [1]. QuickJS has its own test runner but unfortunately there is not automatic bootstraping and they run by hand. There is an upstream PR [2] to add these tests to run there but until that happens we can patch our own QuickJS with. This particular commit doesn't run the tests just patches the necessary updates for bootstrapping and some timeout tweaks to fix some flakes. [1] https://github.com/tc39/test262 [2] bellard/quickjs#408
1 parent 91bd2ed commit 9308ded

File tree

7 files changed

+75
-3
lines changed

7 files changed

+75
-3
lines changed

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

0 commit comments

Comments
 (0)