Skip to content

Commit 666c189

Browse files
committed
test: initial wasm32-wasip2 tests
1 parent de0b3a8 commit 666c189

116 files changed

Lines changed: 2205 additions & 869 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ rustflags = ["-C", "link-arg=/STACK:8388608"]
66

77
[target.wasm32-unknown-unknown]
88
rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""]
9+
10+
[target.wasm32-wasip1]
11+
rustflags = ["-C", "link-arg=-zstack-size=8388608"]

.github/workflows/ci.yml

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
target: wasm32-unknown-unknown
6666
- platform: wasm32-wasi
6767
os: ubuntu-latest
68-
target: wasm32-wasip1-threads
68+
target: wasm32-wasip2
6969

7070
steps:
7171
- name: Checkout source code
@@ -100,7 +100,16 @@ jobs:
100100
cross clippy --workspace --target ${{ matrix.target }} -- -D warnings
101101
102102
- name: Run clippy
103-
if: ${{ matrix.platform != 'wasm32-unknown' && matrix.platform != 'linux-riscv64' && matrix.platform != 'linux-s390x' }}
103+
if: ${{ matrix.platform == 'wasm32-wasi' }}
104+
env:
105+
CARGO_TERM_COLOR: always
106+
RUSTC_BOOTSTRAP: 1
107+
run: |
108+
rustup target install ${{ matrix.target }}
109+
cargo clippy --workspace --target ${{ matrix.target }} -- -D warnings
110+
111+
- name: Run clippy
112+
if: ${{ matrix.platform != 'wasm32-unknown' && matrix.platform != 'linux-riscv64' && matrix.platform != 'linux-s390x' && matrix.platform != 'wasm32-wasi' }}
104113
env:
105114
CARGO_TERM_COLOR: always
106115
run: |
@@ -125,11 +134,51 @@ jobs:
125134
CARGO_TERM_COLOR: always
126135
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
127136
RUST_BACKTRACE: 1
137+
RUSTC_BOOTSTRAP: 1
128138
RUST_LOG: info
129139
run: |
130140
rustup target install ${{ matrix.target }}
131141
cargo build --workspace --target ${{ matrix.target }}
132142
143+
- name: Build
144+
if: ${{ matrix.platform == 'linux-riscv64' || matrix.platform == 'linux-s390x' }}
145+
env:
146+
CARGO_TERM_COLOR: always
147+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
148+
RUST_BACKTRACE: 1
149+
RUST_LOG: info
150+
run: |
151+
cross build --workspace --target ${{ matrix.target }}
152+
153+
- name: Build
154+
if: ${{ matrix.platform != 'wasm32-unknown' && matrix.platform != 'wasm32-wasi' && matrix.platform != 'linux-riscv64' && matrix.platform != 'linux-s390x' }}
155+
env:
156+
CARGO_TERM_COLOR: always
157+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
158+
RUST_BACKTRACE: 1
159+
RUST_LOG: info
160+
run: |
161+
rustup target install ${{ matrix.target }}
162+
cargo build --workspace --target ${{ matrix.target }}
163+
164+
- name: Install wasmtime
165+
if: ${{ matrix.platform == 'wasm32-wasi' }}
166+
uses: taiki-e/install-action@v2
167+
with:
168+
tool: wasmtime
169+
170+
- name: Tests
171+
if: ${{ matrix.platform == 'wasm32-wasi' }}
172+
env:
173+
CARGO_TERM_COLOR: always
174+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
175+
RUST_BACKTRACE: 1
176+
RUST_LOG: info
177+
RUSTC_BOOTSTRAP: 1
178+
CARGO_TARGET_WASM32_WASIP2_RUNNER: "wasmtime -W max-wasm-stack=8388608 -S http -S inherit-network -S allow-ip-name-lookup --dir=. --dir=${{ github.workspace }}::${{ github.workspace }} --env=HOME=/home --dir=${{ runner.temp }}::/home --env=TMPDIR=/tmp --dir=/tmp::/tmp"
179+
run: |
180+
cargo test --workspace --tests --exclude ristretto_classfile --target ${{ matrix.target }} -- --test-threads=1
181+
133182
- name: Tests
134183
if: ${{ !startsWith(matrix.platform, 'wasm32') && matrix.platform != 'linux-riscv64' && matrix.platform != 'linux-s390x' && matrix.platform != 'macos-arm' }}
135184
env:

Cargo.lock

Lines changed: 106 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ members = [
2323
"ristretto_jit",
2424
"ristretto_macros",
2525
"ristretto_pom",
26+
"ristretto_test_util",
2627
"ristretto_types",
2728
"ristretto_vm",
2829
]
@@ -90,6 +91,7 @@ rayon = "1.12.0"
9091
regex = "1.12.3"
9192
reqwest = "0.13.3"
9293
serde = "1.0.228"
94+
serde_json = "1.0.149"
9395
serde_plain = "1.0.2"
9496
socket2 = "0.6.3"
9597
stacker = "0.1.24"
@@ -99,6 +101,7 @@ sys-locale = "0.3.2"
99101
tar = "0.4.45"
100102
tempfile = "3.27.0"
101103
test-log = "0.2.20"
104+
ristretto_test_util = { path = "ristretto_test_util", version = "0.30.0" }
102105
thiserror = "2.0.18"
103106
thread-priority = "3.0.0"
104107
tokio = { version = "1.52.1", default-features = false, features = ["macros", "rt", "sync", "time"] }
@@ -108,6 +111,7 @@ walkdir = "2.5.0"
108111
wasm-bindgen-futures = "0.4.70"
109112
whoami = "2.1.2"
110113
windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_Registry", "Win32_Security"] }
114+
wstd = "0.6.6"
111115
zerocopy = "0.8.47"
112116
zip = { version = "8.6.0", default-features = false }
113117

Cross.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[target.riscv64gc-unknown-linux-gnu]
2+
pre-build = [
3+
"dpkg --add-architecture $CROSS_DEB_ARCH",
4+
"apt-get update && apt-get install --assume-yes gcc-riscv64-linux-gnu",
5+
]
6+
17
[target.riscv64gc-unknown-linux-gnu.env]
28
passthrough = [
39
"PKG_CONFIG_ALLOW_CROSS=1",
@@ -6,6 +12,10 @@ passthrough = [
612

713
[target.s390x-unknown-linux-gnu]
814
image = "ghcr.io/cross-rs/s390x-unknown-linux-gnu:edge"
15+
pre-build = [
16+
"dpkg --add-architecture $CROSS_DEB_ARCH",
17+
"apt-get update && apt-get install --assume-yes gcc-s390x-linux-gnu",
18+
]
919

1020
[target.s390x-unknown-linux-gnu.env]
1121
passthrough = [

examples/runtime_class_loader/src/main.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#![forbid(unsafe_code)]
22

3-
#[cfg(not(target_family = "wasm"))]
43
use ristretto_classloader::{JavaStr, Result, runtime};
54

65
/// Example that loads a class from the Java runtime.
7-
#[cfg(not(target_family = "wasm"))]
86
#[tokio::main(flavor = "current_thread")]
97
async fn main() -> Result<()> {
108
let (_java_home, java_version, class_loader) = runtime::version_class_loader("21").await?;
@@ -17,16 +15,10 @@ async fn main() -> Result<()> {
1715
Ok(())
1816
}
1917

20-
#[cfg(target_family = "wasm")]
21-
fn main() {
22-
// Runtime class loader is not available on wasm targets
23-
}
24-
2518
#[cfg(test)]
2619
mod test {
2720
use super::*;
2821

29-
#[cfg(not(target_family = "wasm"))]
3022
#[test]
3123
fn test_main() -> Result<()> {
3224
main()

ristretto_classfile/tests/jar_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(target_family = "wasm"))]
2+
13
mod utilities;
24

35
use reqwest::Client;

ristretto_classfile/tests/java8_runtime_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(target_family = "wasm"))]
2+
13
mod utilities;
24

35
use anyhow::{Result, anyhow};

0 commit comments

Comments
 (0)