mirror of
https://github.com/uutils/coreutils.git
synced 2026-10-16 02:48:27 -07:00
- Add conditional compilation for WASI target to avoid panics from `std::env::temp_dir()` - Implement fallback logic in `Options` to read TMPDIR environment variable directly on WASI - Update `get_tmpdir_env_or_default()` with WASI-specific handling for temp directory resolution - Add `#[cfg_attr]` annotations to skip host path-dependent tests on WASI sandbox environment - Ignore 14 tests that require host filesystem access when running under wasi_runner - Ignore directory permission test on WASI due to lack of `chmod` support and mode parameter limitations
81 lines
3.3 KiB
YAML
81 lines
3.3 KiB
YAML
# spell-checker:ignore wasip wasmtime
|
|
name: WASI
|
|
|
|
# spell-checker:ignore TRIGGERPATH
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# End the current execution if there is a new changeset in the PR.
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
jobs:
|
|
test_wasi:
|
|
name: Tests
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
job:
|
|
- { target: wasm32-wasip1, rust-flags: "--cfg wasi_runner" }
|
|
- { target: wasm32-wasip2, rust-flags: "--cfg wasi_runner --cfg wasip2_runner" }
|
|
steps:
|
|
- uses: actions/checkout@v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.job.target }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: "${{ matrix.job.target }}"
|
|
- name: Install wasmtime
|
|
run: |
|
|
curl https://wasmtime.dev/install.sh -sSf | bash
|
|
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
|
|
- name: Run unit tests
|
|
env:
|
|
CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime
|
|
CARGO_TARGET_WASM32_WASIP2_RUNNER: wasmtime
|
|
run: |
|
|
# Get all utilities and exclude ones that don't compile for ${{ matrix.job.target }}
|
|
EXCLUDE="df|du|env|more|tac"
|
|
UTILS=$(./util/show-utils.sh | tr ' ' '\n' | grep -vE "^($EXCLUDE)$" | sed 's/^/-p uu_/' | tr '\n' ' ')
|
|
cargo test --target ${{ matrix.job.target }} --no-default-features $UTILS
|
|
- name: Run integration tests via wasmtime
|
|
if: matrix.job.target == 'wasm32-wasip1'
|
|
env:
|
|
RUSTFLAGS: ${{ matrix.job.rust-flags }}
|
|
run: |
|
|
# Build the WASI binary
|
|
cargo build --target ${{ matrix.job.target }} --no-default-features --features feat_wasm
|
|
# Run host-compiled integration tests against the WASI binary.
|
|
# Tests incompatible with WASI are annotated with
|
|
# #[cfg_attr(wasi_runner, ignore)] in the test source files.
|
|
# The binary above is built without default features, so it has no
|
|
# caret diagnostics; the host test crate does have them, hence the
|
|
# not(wasi_runner) in the cfg guarding every `mod diagnostics`.
|
|
# TODO: add integration tests for these tools as WASI support is extended:
|
|
# arch b2sum cksum csplit date dir dircolors fmt join
|
|
# ls md5sum mkdir mv nproc pathchk pr printenv ptx pwd readlink
|
|
# realpath rm rmdir seq sha1sum sha224sum sha256sum sha384sum
|
|
# sha512sum shred sleep sort split tsort uname uniq vdir
|
|
UUTESTS_BINARY_PATH="$(pwd)/target/${{ matrix.job.target }}/debug/coreutils.wasm" \
|
|
UUTESTS_WASM_RUNNER=wasmtime \
|
|
cargo test --test tests -- \
|
|
test_base32:: test_base64:: test_basenc:: test_basename:: \
|
|
test_cat:: test_comm:: test_cp:: test_cut:: test_dirname:: test_echo:: \
|
|
test_expand:: test_expr:: test_factor:: test_false:: test_fold:: \
|
|
test_head:: test_link:: test_ln:: test_mktemp:: test_nl:: test_numfmt:: \
|
|
test_od:: test_paste:: test_printf:: test_shuf:: test_sum:: \
|
|
test_tail:: test_tee:: test_test:: test_touch:: test_tr:: \
|
|
test_true:: test_truncate:: \
|
|
test_unexpand:: test_unlink:: test_wc:: test_yes::
|