Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@
xtask = "run --package xtask --"
dev-setup = "xtask dev-setup"
create-worktree = "xtask create-worktree"

[target.wasm32-unknown-unknown]
runner = "wasm-bindgen-test-runner"
# Mirror the rustflags used by wasm-quarto-hub-client/.cargo/config.toml so any
# wasm32 build invoked from the workspace root (e.g. the pampa wasm_lua test)
# gets the same panic strategy and ABI. Without panic=unwind plus the
# exception-handling target feature, wasm-c-shim's catch_unwind-based
# replacement for Lua's setjmp/longjmp can't catch panics, and any Lua throw
# during mlua initialization aborts the wasm module.
rustflags = [
"-C", "target-feature=+bulk-memory,+exception-handling",
"-C", "panic=unwind",
"-Zwasm-c-abi=spec",
]
11 changes: 11 additions & 0 deletions .claude/rules/wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,14 @@ stages run sequentially within a single task.
If you find yourself wanting to drop `?Send`, that is a signal something
is wrong with the design of the calling context, not with the trait.
Stop and ask before changing it.

## Verify WASM tests when editing WASM code

When modifying any of these files, update `crates/pampa/tests/wasm_lua.rs`:
- `crates/pampa/src/lua/filter.rs` (cfg(target_arch = "wasm32") blocks)
- `crates/pampa/src/lua/shortcode.rs` (cfg(target_arch = "wasm32") blocks)
- `crates/pampa/src/lua/io_wasm.rs`
- `crates/pampa/src/lua/os_wasm.rs`

WASM tests can't run locally on Windows — they run in Linux CI.
See `dev-docs/wasm.md` for the local run command (Linux/macOS).
36 changes: 36 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,39 @@ jobs:
run: cargo nextest run --tests --cargo-profile ci
env:
RUSTFLAGS: "-D warnings"

wasm-tests:
name: WASM Tests
runs-on: ubuntu-latest
# Uses the pinned toolchain from rust-toolchain.toml, which is already a
# nightly with rust-src (required by -Zbuild-std) and the wasm32 target.
# Do NOT override with latest nightly: bd-at72 pinned the toolchain because
# newer nightlies SIGSEGV in LLVM ThinLTO when building this workspace for
# wasm32-unknown-unknown. (The E0152 duplicate-lang-item conflict between
# the prebuilt wasm32 sysroot and -Zbuild-std that this job originally
# worked around no longer reproduces on the pinned toolchain.)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Clang
uses: egor-tensin/setup-clang@v1
with:
version: latest
platform: x64

- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-wasm-tests

- name: Install wasm-bindgen-cli
run: cargo xtask dev-setup

- name: Run WASM tests
run: |
CC_wasm32_unknown_unknown=clang \
CFLAGS_wasm32_unknown_unknown="-isystem ${{ github.workspace }}/crates/wasm-quarto-hub-client/wasm-sysroot -fno-builtin" \
cargo test -p pampa --test wasm_lua --target wasm32-unknown-unknown \
--no-default-features --features lua-filter -Zbuild-std=std,panic_unwind,panic_abort
72 changes: 70 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ verbose_file_reads = "warn"

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