Skip to content

Commit dd86bd0

Browse files
authored
Add a script to simplify running the wpt tests locally (#171)
1 parent 56e9e48 commit dd86bd0

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/wpt-harness/run-wpt.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
# Use this script to run the wpt test harness locally. You'll need to have the
4+
# following executables in your path:
5+
#
6+
# * wizer
7+
# * node
8+
#
9+
# From any directory, run this script and it will do the following:
10+
#
11+
# 1. build js-compute-runtime.wasm and move it into the current directory
12+
# 2. build the wpt runner
13+
# 3. run the test suite and forward any arguments to it
14+
#
15+
# If you'd like to run a debug build, set the `DEBUG` environment variable when
16+
# running this script:
17+
#
18+
# > mkdir my_test
19+
# > cd my_test
20+
# > DEBUG=true ../tests/wpt-harness/run-wpt.sh
21+
#
22+
# For this to work, you'll need to have run the following command in advance:
23+
#
24+
# > cd c-dependencies/spidermonkey
25+
# > ./download-engine.sh debug
26+
#
27+
# If you get an error about missing "jsapi.h" while building the runtime,
28+
# something's gone wrong with the engine download.
29+
30+
set -euo pipefail
31+
32+
working_dir="$(pwd)"
33+
root="$(dirname "${BASH_SOURCE[0]}")/../.."
34+
35+
output="$(mktemp)"
36+
trap 'rm $output' EXIT
37+
38+
echo "Building the runtime..."
39+
cd "$root/c-dependencies/js-compute-runtime"
40+
if ! make -j8 > "$output" 2>&1; then
41+
cat "$output"
42+
exit 1
43+
fi
44+
cp js-compute-runtime.wasm "$working_dir"
45+
46+
cd "$working_dir"
47+
48+
echo "Building the wpt runtime..."
49+
bash "$root/tests/wpt-harness/build-wpt-runtime.sh"
50+
51+
echo "Running the wpt tests..."
52+
node "$root/tests/wpt-harness/run-wpt.mjs" "$@"

0 commit comments

Comments
 (0)