From 3c38f29ab4917f728c655ee2140b68e10eb0cbb6 Mon Sep 17 00:00:00 2001 From: Nick Vatamaniuc Date: Mon, 12 May 2025 23:35:22 -0400 Subject: [PATCH] Run test262 tests in CI Run test262 tests for Linux, macOS and Cosmopolitan Add a Makefile `test2-bootstrap` helper to clone and patch test262 tests at a particular commit. Running with the latest commit noticed a few tests were failing and added them to the errors list. The CI environment, especially for macOS, was a bit more unpredictable and was failing in atomics tests due to lower timeouts in the `atomicsHelper` so double the timeouts. The time didn't worsen too much. It still takes about 2-3 min. --- .github/workflows/ci.yml | 17 +++++++++++++++++ Makefile | 13 +++++++++++++ test262.conf | 1 + tests/test262.patch | 6 +++--- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9ccf6249..46ef22134 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,10 @@ jobs: - name: Run microbench run: | make microbench + - name: Run test262 + run: | + make test2-bootstrap + make test2 linux-lto: name: Linux LTO @@ -138,6 +142,10 @@ jobs: - name: Run built-in tests run: | make test + - name: Run test262 + run: | + make test2-bootstrap + make test2 macos-asan: runs-on: macos-latest @@ -172,7 +180,12 @@ jobs: - name: Build + test uses: vmactions/freebsd-vm@v1 with: + # This VM has a tendency to get stuck in the "VM is booting" cycle + # for quite a while, so set a shorter timeout + timeout-minutes: 15 usesh: true + copyback: false + mem: 16384 prepare: | pkg install -y gmake run: | @@ -202,6 +215,10 @@ jobs: - name: Run built-in tests run: | make CONFIG_COSMO=y test + - name: Run test262 + run: | + make test2-bootstrap + make CONFIG_COSMO=y test2 mingw-windows: name: MinGW Windows target diff --git a/Makefile b/Makefile index 3b1c74594..b11f940b7 100644 --- a/Makefile +++ b/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?=3fd4ec27f1798ebecafc73b354a45dcdda9bde29 +TEST262_SINCE?=2025-08-25 + 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/test262.conf b/test262.conf index c099f2fe6..c5ac2ddeb 100644 --- a/test262.conf +++ b/test262.conf @@ -116,6 +116,7 @@ for-of generators globalThis hashbang +immutable-arraybuffer=skip import-attributes import-defer=skip import.meta diff --git a/tests/test262.patch b/tests/test262.patch index 6956d15b1..e488df829 100644 --- a/tests/test262.patch +++ b/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, };