Skip to content

Commit 3df8a56

Browse files
committed
Test262: add a native runner for the official suite
1 parent 1a8c672 commit 3df8a56

6 files changed

Lines changed: 8807 additions & 0 deletions

File tree

.github/workflows/test262.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: test262
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
13+
14+
jobs:
15+
test262:
16+
runs-on: ubuntu-24.04
17+
timeout-minutes: 20
18+
19+
steps:
20+
- name: Checkout njs
21+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
22+
23+
- name: Install build dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install clang-18 libssl-dev zlib1g-dev libpcre2-dev \
27+
libxml2-dev
28+
29+
- name: Checkout test262
30+
run: |
31+
test262_sha=$(cat test/njs_test262.version)
32+
git clone --depth=1 https://github.com/tc39/test262 test262
33+
git -C test262 fetch --depth=1 origin "$test262_sha"
34+
git -C test262 checkout --detach "$test262_sha"
35+
test "$(git -C test262 rev-parse HEAD)" = "$test262_sha"
36+
37+
- name: Build test262
38+
run: |
39+
./configure
40+
make -j$(nproc) njs_test262
41+
42+
- name: Run test262
43+
run: |
44+
TZ=UTC timeout 15m build/njs_test262 \
45+
--config test/njs_test262.conf \
46+
--suite "$GITHUB_WORKSPACE/test262" \
47+
--failures "$GITHUB_WORKSPACE/test/njs_test262.failures" \
48+
--isolation=process \
49+
--timeout=5
50+
51+
- name: Build test262 with UBSan
52+
run: |
53+
make clean
54+
CC=clang-18 ./configure --cc-opt='-O2 -fsanitize=undefined' \
55+
--ld-opt='-fsanitize=undefined'
56+
make -j$(nproc) njs_test262
57+
58+
- name: Run test262 with UBSan
59+
run: |
60+
TZ=UTC UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 \
61+
timeout 15m build/njs_test262 \
62+
--config test/njs_test262.conf \
63+
--suite "$GITHUB_WORKSPACE/test262" \
64+
--failures "$GITHUB_WORKSPACE/test/njs_test262.failures" \
65+
--isolation=process \
66+
--timeout=5
67+
68+
- name: Build test262 with ASan
69+
run: |
70+
make clean
71+
CC=clang-18 ./configure --address-sanitizer=YES --cc-opt=-O2
72+
make -j$(nproc) njs_test262
73+
74+
- name: Run test262 with ASan
75+
run: |
76+
TZ=UTC ASAN_OPTIONS=detect_leaks=0 timeout 15m build/njs_test262 \
77+
--config test/njs_test262.conf \
78+
--suite "$GITHUB_WORKSPACE/test262" \
79+
--failures "$GITHUB_WORKSPACE/test/njs_test262.failures" \
80+
--isolation=process \
81+
--timeout=5

auto/make

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,30 @@ END
282282

283283
done
284284

285+
# test262 runner.
286+
287+
njs_src="src/test/njs_test262.c"
288+
fname=$(basename $njs_src)
289+
njs_dep="test/${fname%.c}.dep"
290+
njs_bin="${fname%.c}"
291+
njs_dep_flags=`njs_gen_dep_flags $njs_dep $fname`
292+
njs_dep_post=`njs_gen_dep_post $njs_dep $fname`
293+
294+
cat << END >> $NJS_MAKEFILE
295+
296+
$NJS_BUILD_DIR/$njs_bin: $njs_src \\
297+
$NJS_BUILD_DIR/libnjs.a
298+
\$(NJS_LINK) -o $NJS_BUILD_DIR/$njs_bin \$(NJS_LIB_INCS) \\
299+
\$(CFLAGS) \$(NJS_LIB_AUX_CFLAGS) \\
300+
$njs_dep_flags \\
301+
$njs_src $NJS_BUILD_DIR/libnjs.a \\
302+
$NJS_LD_OPT -lm $NJS_LIBS $NJS_LIB_AUX_LIBS
303+
$njs_dep_post
304+
305+
-include $NJS_BUILD_DIR/$njs_dep
306+
307+
END
308+
285309
# main targets.
286310

287311
cat << END >> $NJS_MAKEFILE
@@ -313,6 +337,20 @@ lib_test: $NJS_BUILD_DIR/njs_auto_config.h \\
313337
test262_njs: njs
314338
test/test262 --binary=$NJS_BUILD_DIR/njs
315339

340+
njs_test262: $NJS_BUILD_DIR/njs_auto_config.h \\
341+
$NJS_BUILD_DIR/njs_test262
342+
343+
njs_test262_test: njs_test262
344+
345+
@test -n "\$\$NJS_TEST262_DIR" || { \\
346+
echo "NJS_TEST262_DIR is not set, it must point at a"; \\
347+
echo "test262 checkout containing test/ and harness/"; \\
348+
exit 1; \\
349+
}
350+
$NJS_BUILD_DIR/njs_test262 -c test/njs_test262.conf \\
351+
--failures test/njs_test262.failures --isolation=process \\
352+
--timeout=5
353+
316354
unit_test: $NJS_BUILD_DIR/njs_auto_config.h \\
317355
$NJS_BUILD_DIR/njs_unit_test
318356

0 commit comments

Comments
 (0)