This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch jenkins-add-test262-to-quickjs
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9308ded4e12e799f80f52149a586d059fa69c530
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Sat Jun 14 01:14:01 2025 -0400

    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] https://github.com/bellard/quickjs/pull/408
---
 src/couch_quickjs/.gitignore                       |  2 ++
 .../patches/02-test262-makefile.patch              | 29 ++++++++++++++++++++++
 src/couch_quickjs/patches/03-test262-yield.patch   | 15 +++++++++++
 src/couch_quickjs/patches/04-test262-errors.patch  | 11 ++++++++
 src/couch_quickjs/quickjs/Makefile                 | 13 ++++++++++
 src/couch_quickjs/quickjs/test262_errors.txt       |  2 ++
 src/couch_quickjs/quickjs/tests/test262.patch      |  6 ++---
 7 files changed, 75 insertions(+), 3 deletions(-)

diff --git a/src/couch_quickjs/.gitignore b/src/couch_quickjs/.gitignore
index dd78afee1..f7d339351 100644
--- a/src/couch_quickjs/.gitignore
+++ b/src/couch_quickjs/.gitignore
@@ -16,6 +16,8 @@
 /quickjs/qjscalc.c
 /quickjs/repl.c
 /quickjs/run-test262
+/quickjs/test262_report.txt
+/quickjs/test262/
 /quickjs/test_fib.c
 /quickjs/.github
 compile_commands.json
diff --git a/src/couch_quickjs/patches/02-test262-makefile.patch 
b/src/couch_quickjs/patches/02-test262-makefile.patch
new file mode 100644
index 000000000..33023af58
--- /dev/null
+++ b/src/couch_quickjs/patches/02-test262-makefile.patch
@@ -0,0 +1,29 @@
+--- quickjs-master/Makefile    2025-05-29 14:01:24
++++ quickjs/Makefile   2025-06-14 01:47:22
+@@ -53,6 +53,10 @@
+ #CONFIG_MSAN=y
+ # use UB sanitizer
+ #CONFIG_UBSAN=y
++
++# TEST262 bootstrap config: commit id and shallow "since" parameter
++TEST262_COMMIT?=3316c0aaf676d657f5a6b33364fa7e579c78ac7f
++TEST262_SINCE?=2025-05-21
+ 
+ OBJDIR=.obj
+ 
+@@ -464,6 +468,15 @@
+ microbench: qjs$(EXE)
+       $(WINE) ./qjs$(EXE) --std tests/microbench.js
+ 
++ifeq ($(wildcard test262/features.txt),)
++test2-bootstrap:
++      git clone --single-branch --shallow-since=$(TEST262_SINCE) 
https://github.com/tc39/test262.git
++      (cd test262 && git checkout -q $(TEST262_COMMIT) && patch -p1 < 
../tests/test262.patch && cd ..)
++else
++test2-bootstrap:
++      (cd test262 && git fetch && git reset --hard $(TEST262_COMMIT) && patch 
-p1 < ../tests/test262.patch && cd ..)
++endif
++
+ ifeq ($(wildcard test262o/tests.txt),)
+ test2o test2o-update:
+       @echo test262o tests not installed
diff --git a/src/couch_quickjs/patches/03-test262-yield.patch 
b/src/couch_quickjs/patches/03-test262-yield.patch
new file mode 100644
index 000000000..664e9c3ce
--- /dev/null
+++ b/src/couch_quickjs/patches/03-test262-yield.patch
@@ -0,0 +1,15 @@
+--- quickjs-master/tests/test262.patch 2025-05-29 14:01:24
++++ quickjs/tests/test262.patch        2025-06-03 23:44:41
+@@ -14,9 +14,9 @@
+ +//  small: 200,
+ +//  long: 1000,
+ +//  huge: 10000,
+-+  yield: 20,
+-+  small: 20,
+-+  long: 100,
+++  yield: 40,
+++  small: 40,
+++  long: 200,
+ +  huge: 1000,
+  };
+  
diff --git a/src/couch_quickjs/patches/04-test262-errors.patch 
b/src/couch_quickjs/patches/04-test262-errors.patch
new file mode 100644
index 000000000..b41369aa3
--- /dev/null
+++ b/src/couch_quickjs/patches/04-test262-errors.patch
@@ -0,0 +1,11 @@
+--- quickjs-master/test262_errors.txt  2025-05-29 14:01:24
++++ quickjs/test262_errors.txt 2025-06-14 02:31:58
+@@ -1,6 +1,8 @@
+ 
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34:
 TypeError: ArrayBuffer is detached
+ 
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34:
 strict mode: TypeError: ArrayBuffer is detached
+ 
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10:
 TypeError: $DONE() not called
++test262/test/language/statements/expression/S12.4_A1.js:15: unexpected error 
type: Test262: This statement should not be evaluated.
++test262/test/language/statements/expression/S12.4_A1.js:15: strict mode: 
unexpected error type: Test262: This statement should not be evaluated.
+ 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
+ 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
+ test262/test/staging/sm/Date/non-iso.js:76: Test262Error: Expected 
SameValue(«NaN», «-40071559730000») to be true
diff --git a/src/couch_quickjs/quickjs/Makefile 
b/src/couch_quickjs/quickjs/Makefile
index 3b1c74594..fd74c7be2 100644
--- a/src/couch_quickjs/quickjs/Makefile
+++ b/src/couch_quickjs/quickjs/Makefile
@@ -54,6 +54,10 @@ PREFIX?=/usr/local
 # use UB sanitizer
 #CONFIG_UBSAN=y
 
+# TEST262 bootstrap config: commit id and shallow "since" parameter
+TEST262_COMMIT?=3316c0aaf676d657f5a6b33364fa7e579c78ac7f
+TEST262_SINCE?=2025-05-21
+
 OBJDIR=.obj
 
 ifdef CONFIG_ASAN
@@ -464,6 +468,15 @@ stats: qjs$(EXE)
 microbench: qjs$(EXE)
        $(WINE) ./qjs$(EXE) --std tests/microbench.js
 
+ifeq ($(wildcard test262/features.txt),)
+test2-bootstrap:
+       git clone --single-branch --shallow-since=$(TEST262_SINCE) 
https://github.com/tc39/test262.git
+       (cd test262 && git checkout -q $(TEST262_COMMIT) && patch -p1 < 
../tests/test262.patch && cd ..)
+else
+test2-bootstrap:
+       (cd test262 && git fetch && git reset --hard $(TEST262_COMMIT) && patch 
-p1 < ../tests/test262.patch && cd ..)
+endif
+
 ifeq ($(wildcard test262o/tests.txt),)
 test2o test2o-update:
        @echo test262o tests not installed
diff --git a/src/couch_quickjs/quickjs/test262_errors.txt 
b/src/couch_quickjs/quickjs/test262_errors.txt
index 9df6f749a..e32145bdb 100644
--- a/src/couch_quickjs/quickjs/test262_errors.txt
+++ b/src/couch_quickjs/quickjs/test262_errors.txt
@@ -1,6 +1,8 @@
 
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34:
 TypeError: ArrayBuffer is detached
 
test262/test/built-ins/Atomics/notify/retrieve-length-before-index-coercion-non-shared-detached.js:34:
 strict mode: TypeError: ArrayBuffer is detached
 
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10:
 TypeError: $DONE() not called
+test262/test/language/statements/expression/S12.4_A1.js:15: unexpected error 
type: Test262: This statement should not be evaluated.
+test262/test/language/statements/expression/S12.4_A1.js:15: strict mode: 
unexpected error type: Test262: This statement should not be evaluated.
 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
 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
 test262/test/staging/sm/Date/non-iso.js:76: Test262Error: Expected 
SameValue(«NaN», «-40071559730000») to be true
diff --git a/src/couch_quickjs/quickjs/tests/test262.patch 
b/src/couch_quickjs/quickjs/tests/test262.patch
index 4ed0afb8e..c8885e658 100644
--- a/src/couch_quickjs/quickjs/tests/test262.patch
+++ b/src/couch_quickjs/quickjs/tests/test262.patch
@@ -14,9 +14,9 @@ index 9828b15..4a5919d 100644
 +//  small: 200,
 +//  long: 1000,
 +//  huge: 10000,
-+  yield: 20,
-+  small: 20,
-+  long: 100,
++  yield: 40,
++  small: 40,
++  long: 200,
 +  huge: 1000,
  };
  

Reply via email to