Skip to content

Commit e984c89

Browse files
authored
Add V8 testing on CI (#7208)
This adds v8 from jsvu to CI, and a single lit test that uses it, to get started. The tests are skipped on Alpine Linux, which jsvu is not compatible with. To do so, we just delete the tests before running lit (for lack of a better skipping mechanism, as `lit --xfail` is not supported in our lit on CI).
1 parent 8623f73 commit e984c89

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ jobs:
7575
run: choco install ninja
7676
if: matrix.os == 'windows-latest'
7777

78+
- name: install v8
79+
run: |
80+
npm install jsvu -g
81+
jsvu --os=default --engines=v8
82+
7883
- name: mkdir
7984
run: mkdir -p out
8085

@@ -125,6 +130,10 @@ jobs:
125130
submodules: true
126131
- name: install ninja
127132
run: sudo apt-get install ninja-build
133+
- name: install v8
134+
run: |
135+
npm install jsvu -g
136+
jsvu --os=default --engines=v8
128137
- name: install Python dev dependencies
129138
run: pip3 install -r requirements-dev.txt
130139
- name: cmake
@@ -161,6 +170,10 @@ jobs:
161170
sudo ./llvm.sh 18
162171
- name: install ninja
163172
run: sudo apt-get install ninja-build
173+
- name: install v8
174+
run: |
175+
npm install jsvu -g
176+
jsvu --os=default --engines=v8
164177
- name: install Python dev dependencies
165178
run: pip3 install -r requirements-dev.txt
166179
- name: cmake
@@ -196,6 +209,10 @@ jobs:
196209
./alpine.sh apk update
197210
./alpine.sh apk add build-base cmake git python3 py3-pip clang ninja
198211
212+
- name: avoid d8 tests (jsvu is not compatible with alpine)
213+
run: |
214+
./alpine.sh rm -Rf test/lit/d8
215+
199216
- name: install python dev dependencies
200217
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt
201218

@@ -227,6 +244,10 @@ jobs:
227244
submodules: true
228245
- name: install ninja
229246
run: sudo apt-get install ninja-build
247+
- name: install v8
248+
run: |
249+
npm install jsvu -g
250+
jsvu --os=default --engines=v8
230251
- name: install Python dev dependencies
231252
run: pip3 install -r requirements-dev.txt
232253
- name: cmake
@@ -261,6 +282,10 @@ jobs:
261282
sudo ./llvm.sh 18
262283
- name: install ninja
263284
run: sudo apt-get install ninja-build
285+
- name: install v8
286+
run: |
287+
npm install jsvu -g
288+
jsvu --os=default --engines=v8
264289
- name: install Python dev dependencies
265290
run: pip3 install -r requirements-dev.txt
266291
- name: cmake
@@ -344,6 +369,10 @@ jobs:
344369
submodules: true
345370
- name: install ninja
346371
run: sudo apt-get install ninja-build
372+
- name: install v8
373+
run: |
374+
npm install jsvu -g
375+
jsvu --os=default --engines=v8
347376
- name: install Python dev dependencies
348377
run: pip3 install -r requirements-dev.txt
349378
- name: cmake
@@ -378,6 +407,10 @@ jobs:
378407
submodules: true
379408
- name: install ninja
380409
run: sudo apt-get install ninja-build
410+
- name: install v8
411+
run: |
412+
npm install jsvu -g
413+
jsvu --os=default --engines=v8
381414
- name: install Python dev dependencies
382415
run: pip3 install -r requirements-dev.txt
383416
- name: cmake

.github/workflows/create_release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,15 @@ jobs:
126126
echo 'docker exec alpine "$@";' > ./alpine.sh
127127
chmod +x ./alpine.sh
128128
129-
130129
- name: install packages
131130
run: |
132131
./alpine.sh apk update
133132
./alpine.sh apk add build-base cmake git python3 clang ninja py3-pip
134133
134+
- name: avoid d8 tests (jsvu is not compatible with alpine)
135+
run: |
136+
./alpine.sh rm -Rf test/lit/d8
137+
135138
- name: install python dev dependencies
136139
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt
137140

test/lit/d8/fuzz_shell.wast

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
;; Test running a wasm file in fuzz_shell.js.
2+
3+
(module
4+
(func $test (export "test") (result i32)
5+
(i32.const 42)
6+
)
7+
)
8+
9+
;; Build to a binary wasm.
10+
;;
11+
;; RUN: wasm-opt %s -o %t.wasm -q
12+
13+
;; Run in d8.
14+
;;
15+
;; RUN: v8 %S/../../../scripts/fuzz_shell.js -- %t.wasm | filecheck %s
16+
;;
17+
;; CHECK: [fuzz-exec] calling test
18+
;; CHECK: [fuzz-exec] note result: test => 42
19+

test/lit/lit.cfg.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,38 @@
2525
tool_file = config.binaryen_src_root + '/scripts/' + tool + '.py'
2626
python = sys.executable.replace('\\', '/')
2727
config.substitutions.append((tool, python + ' ' + tool_file))
28+
29+
# Finds the given executable 'program' in PATH.
30+
# Operates like the Unix tool 'which'.
31+
# This is similar to script/test/shared.py, but does not use binaryen_root, and
32+
# instead is tuned to jsvu's install dir.
33+
def which(program):
34+
def is_exe(fpath):
35+
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
36+
fpath, fname = os.path.split(program)
37+
if fpath:
38+
if is_exe(program):
39+
return program
40+
else:
41+
# Prefer the path, or jsvu's install dir.
42+
paths = os.environ['PATH'].split(os.pathsep) + [
43+
os.path.expanduser('~/.jsvu/bin'),
44+
]
45+
for path in paths:
46+
path = path.strip('"')
47+
exe_file = os.path.join(path, program)
48+
if is_exe(exe_file):
49+
return exe_file
50+
if '.' not in fname:
51+
if is_exe(exe_file + '.exe'):
52+
return exe_file + '.exe'
53+
if is_exe(exe_file + '.cmd'):
54+
return exe_file + '.cmd'
55+
if is_exe(exe_file + '.bat'):
56+
return exe_file + '.bat'
57+
58+
# v8 may be provided by jsvu, or it may be "d8". It may also not exist at all,
59+
# in which case the relevant lit tests should be skipped.
60+
V8 = os.environ.get('V8') or which('v8') or which('d8')
61+
if V8:
62+
config.substitutions.append(('v8', V8))

0 commit comments

Comments
 (0)