Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add V8 testing on CI #7208

Merged
merged 17 commits into from
Jan 17, 2025
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ jobs:
run: choco install ninja
if: matrix.os == 'windows-latest'

- name: install v8
run: |
npm install jsvu -g
jsvu --os=default --engines=v8

- name: mkdir
run: mkdir -p out

Expand Down Expand Up @@ -125,6 +130,10 @@ jobs:
submodules: true
- name: install ninja
run: sudo apt-get install ninja-build
- name: install v8
run: |
npm install jsvu -g
jsvu --os=default --engines=v8
- name: install Python dev dependencies
run: pip3 install -r requirements-dev.txt
- name: cmake
Expand Down Expand Up @@ -161,6 +170,10 @@ jobs:
sudo ./llvm.sh 18
- name: install ninja
run: sudo apt-get install ninja-build
- name: install v8
run: |
npm install jsvu -g
jsvu --os=default --engines=v8
- name: install Python dev dependencies
run: pip3 install -r requirements-dev.txt
- name: cmake
Expand Down Expand Up @@ -196,6 +209,10 @@ jobs:
./alpine.sh apk update
./alpine.sh apk add build-base cmake git python3 py3-pip clang ninja

- name: avoid d8 tests (jsvu is not compatible with alpine)
run: |
./alpine.sh rm -Rf test/lit/d8

- name: install python dev dependencies
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt

Expand Down Expand Up @@ -227,6 +244,10 @@ jobs:
submodules: true
- name: install ninja
run: sudo apt-get install ninja-build
- name: install v8
run: |
npm install jsvu -g
jsvu --os=default --engines=v8
- name: install Python dev dependencies
run: pip3 install -r requirements-dev.txt
- name: cmake
Expand Down Expand Up @@ -261,6 +282,10 @@ jobs:
sudo ./llvm.sh 18
- name: install ninja
run: sudo apt-get install ninja-build
- name: install v8
run: |
npm install jsvu -g
jsvu --os=default --engines=v8
- name: install Python dev dependencies
run: pip3 install -r requirements-dev.txt
- name: cmake
Expand Down Expand Up @@ -344,6 +369,10 @@ jobs:
submodules: true
- name: install ninja
run: sudo apt-get install ninja-build
- name: install v8
run: |
npm install jsvu -g
jsvu --os=default --engines=v8
- name: install Python dev dependencies
run: pip3 install -r requirements-dev.txt
- name: cmake
Expand Down Expand Up @@ -378,6 +407,10 @@ jobs:
submodules: true
- name: install ninja
run: sudo apt-get install ninja-build
- name: install v8
run: |
npm install jsvu -g
jsvu --os=default --engines=v8
- name: install Python dev dependencies
run: pip3 install -r requirements-dev.txt
- name: cmake
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,15 @@ jobs:
echo 'docker exec alpine "$@";' > ./alpine.sh
chmod +x ./alpine.sh


- name: install packages
run: |
./alpine.sh apk update
./alpine.sh apk add build-base cmake git python3 clang ninja py3-pip

- name: avoid d8 tests (jsvu is not compatible with alpine)
run: |
./alpine.sh rm -Rf test/lit/d8

- name: install python dev dependencies
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt

Expand Down
19 changes: 19 additions & 0 deletions test/lit/d8/fuzz_shell.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
;; Test running a wasm file in fuzz_shell.js.

(module
(func $test (export "test") (result i32)
(i32.const 42)
)
)

;; Build to a binary wasm.
;;
;; RUN: wasm-opt %s -o %t.wasm -q

;; Run in d8.
;;
;; RUN: v8 %S/../../../scripts/fuzz_shell.js -- %t.wasm | filecheck %s
;;
;; CHECK: [fuzz-exec] calling test
;; CHECK: [fuzz-exec] note result: test => 42

35 changes: 35 additions & 0 deletions test/lit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,38 @@
tool_file = config.binaryen_src_root + '/scripts/' + tool + '.py'
python = sys.executable.replace('\\', '/')
config.substitutions.append((tool, python + ' ' + tool_file))

# Finds the given executable 'program' in PATH.
# Operates like the Unix tool 'which'.
# This is similar to script/test/shared.py, but does not use binaryen_root, and
# instead is tuned to jsvu's install dir.
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
# Prefer the path, or jsvu's install dir.
paths = os.environ['PATH'].split(os.pathsep) + [
os.path.expanduser('~/.jsvu/bin'),
]
for path in paths:
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
if '.' not in fname:
if is_exe(exe_file + '.exe'):
return exe_file + '.exe'
if is_exe(exe_file + '.cmd'):
return exe_file + '.cmd'
if is_exe(exe_file + '.bat'):
return exe_file + '.bat'

# v8 may be provided by jsvu, or it may be "d8". It may also not exist at all,
# in which case the relevant lit tests should be skipped.
V8 = os.environ.get('V8') or which('v8') or which('d8')
if V8:
config.substitutions.append(('v8', V8))
Loading