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 ae6dc54d95fce4ed3b7e4de66c17c0db4510d909
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Sat Jun 14 01:14:01 2025 -0400

    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] https://github.com/bellard/quickjs/pull/408
---
 Makefile                                           |  6 +++++
 build-aux/Jenkinsfile.full                         |  1 +
 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 ++---
 src/couch_quickjs/run_test262_tests.sh             | 16 ++++++++++++
 10 files changed, 98 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index fdab740a0..4be01edbe 100644
--- a/Makefile
+++ b/Makefile
@@ -354,6 +354,12 @@ weatherreport-test: devclean escriptize
        @dev/run "$(TEST_OPTS)" -n 1 -a adm:pass --no-eval \
                'bin/weatherreport --etc dev/lib/node1/etc --level error'
 
+.PHONY: quickjs-javascript-test
+# target: quickjs-javascript-tests - Run QuickJS JS conformance tests
+quickjs-javascript-tests: couch
+       @make -C src/couch_quickjs/quickjs test2-bootstrap
+       @make -C src/couch_quickjs/quickjs test2
+
 
################################################################################
 # Developing
 
################################################################################
diff --git a/build-aux/Jenkinsfile.full b/build-aux/Jenkinsfile.full
index 1efc96532..cf8d1930f 100644
--- a/build-aux/Jenkinsfile.full
+++ b/build-aux/Jenkinsfile.full
@@ -312,6 +312,7 @@ def generateContainerStage(platform) {
                   dir( "${platform}/build" ) {
                     sh "${configure(meta[platform])}"
                     sh 'make'
+                    retry(1) {sh 'make quickjs-javascript-test'}
                     retry(3) {sh 'make eunit'}
                     retry(3) {sh 'make elixir'}
                     retry(3) {sh 'make elixir-search'}
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,
  };
  
diff --git a/src/couch_quickjs/run_test262_tests.sh 
b/src/couch_quickjs/run_test262_tests.sh
new file mode 100755
index 000000000..b947b389d
--- /dev/null
+++ b/src/couch_quickjs/run_test262_tests.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+
+DIR=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")
+
+echo "+++++++++++++++++++++ Set up test262 repo +++++++++++++++++++++++"
+make -C ${DIR}/quickjs test2-bootstrap
+echo
+echo "++++++++++++++++++++++ Build test runner ++++++++++++++++++++++++"
+make -C ${DIR}/quickjs run-test262
+echo
+echo "++++++++++++++++++++++ Run test262 tests ++++++++++++++++++++++++"
+make -C ${DIR}/quickjs test2
+echo

Reply via email to