Skip to content

Commit e26a8b8

Browse files
Merge pull request #109 from quarto-dev/feature/wasm-testing-and-cleanup
Add real wasm32 smoke tests and CI job
2 parents 0efb27e + bf370a0 commit e26a8b8

20 files changed

Lines changed: 2488 additions & 54 deletions

File tree

.cargo/config.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,17 @@
66
xtask = "run --package xtask --"
77
dev-setup = "xtask dev-setup"
88
create-worktree = "xtask create-worktree"
9+
10+
[target.wasm32-unknown-unknown]
11+
runner = "wasm-bindgen-test-runner"
12+
# Mirror the rustflags used by wasm-quarto-hub-client/.cargo/config.toml so any
13+
# wasm32 build invoked from the workspace root (e.g. the pampa wasm_lua test)
14+
# gets the same panic strategy and ABI. Without panic=unwind plus the
15+
# exception-handling target feature, wasm-c-shim's catch_unwind-based
16+
# replacement for Lua's setjmp/longjmp can't catch panics, and any Lua throw
17+
# during mlua initialization aborts the wasm module.
18+
rustflags = [
19+
"-C", "target-feature=+bulk-memory,+exception-handling",
20+
"-C", "panic=unwind",
21+
"-Zwasm-c-abi=spec",
22+
]

.claude/rules/wasm.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,14 @@ stages run sequentially within a single task.
5252
If you find yourself wanting to drop `?Send`, that is a signal something
5353
is wrong with the design of the calling context, not with the trait.
5454
Stop and ask before changing it.
55+
56+
## Verify WASM tests when editing WASM code
57+
58+
When modifying any of these files, update `crates/pampa/tests/wasm_lua.rs`:
59+
- `crates/pampa/src/lua/filter.rs` (cfg(target_arch = "wasm32") blocks)
60+
- `crates/pampa/src/lua/shortcode.rs` (cfg(target_arch = "wasm32") blocks)
61+
- `crates/pampa/src/lua/io_wasm.rs`
62+
- `crates/pampa/src/lua/os_wasm.rs`
63+
64+
WASM tests can't run locally on Windows — they run in Linux CI.
65+
See `dev-docs/wasm.md` for the local run command (Linux/macOS).

.github/workflows/test-suite.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,39 @@ jobs:
179179
run: cargo nextest run --tests --cargo-profile ci
180180
env:
181181
RUSTFLAGS: "-D warnings"
182+
183+
wasm-tests:
184+
name: WASM Tests
185+
runs-on: ubuntu-latest
186+
# Uses the pinned toolchain from rust-toolchain.toml, which is already a
187+
# nightly with rust-src (required by -Zbuild-std) and the wasm32 target.
188+
# Do NOT override with latest nightly: bd-at72 pinned the toolchain because
189+
# newer nightlies SIGSEGV in LLVM ThinLTO when building this workspace for
190+
# wasm32-unknown-unknown. (The E0152 duplicate-lang-item conflict between
191+
# the prebuilt wasm32 sysroot and -Zbuild-std that this job originally
192+
# worked around no longer reproduces on the pinned toolchain.)
193+
steps:
194+
- uses: actions/checkout@v4
195+
with:
196+
fetch-depth: 1
197+
198+
- name: Set up Clang
199+
uses: egor-tensin/setup-clang@v1
200+
with:
201+
version: latest
202+
platform: x64
203+
204+
- name: Rust cache
205+
uses: Swatinem/rust-cache@v2
206+
with:
207+
shared-key: rust-wasm-tests
208+
209+
- name: Install wasm-bindgen-cli
210+
run: cargo xtask dev-setup
211+
212+
- name: Run WASM tests
213+
run: |
214+
CC_wasm32_unknown_unknown=clang \
215+
CFLAGS_wasm32_unknown_unknown="-isystem ${{ github.workspace }}/crates/wasm-quarto-hub-client/wasm-sysroot -fno-builtin" \
216+
cargo test -p pampa --test wasm_lua --target wasm32-unknown-unknown \
217+
--no-default-features --features lua-filter -Zbuild-std=std,panic_unwind,panic_abort

Cargo.lock

Lines changed: 70 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ verbose_file_reads = "warn"
274274

275275
[patch.crates-io]
276276
lua-src = { path = "crates/lua-src-wasm" }
277+
# Neutralize tree-sitter-language's upstream wasm32 stdio/stdlib/string C
278+
# stubs so wasm-c-shim is the single source of truth for C stdlib symbols
279+
# in workspace wasm32 builds (the pampa wasm_lua tests). Same patch as
280+
# wasm-quarto-hub-client's; identical Rust source on native targets, and
281+
# its build.rs is a no-op off-wasm32. See
282+
# claude-notes/plans/2026-04-20-wasm-shim-merge.md.
283+
tree-sitter-language = { path = "crates/tree-sitter-language-wasm-shim" }
277284
# Fork of runtimelib that adds venv-aware kernelspec discovery
278285
# (`data_dirs_with_jupyter_paths`, `find_kernelspec_with_jupyter_paths`)
279286
# and threads `searched_paths` through `RuntimeError::KernelNotFound`.

0 commit comments

Comments
 (0)