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

Configure WASM tests an try isatty on wasi #155

Merged
merged 5 commits into from
Jan 16, 2023
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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.wasm32-wasi]
runner = ["./scripts/wasmtime-wrapper.sh"]
33 changes: 30 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ jobs:
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
run: make test
wasm:
name: Wasm
wasm-check:
name: WASM Check
strategy:
fail-fast: false
matrix:
target: [wasm32-unknown-unknown, wasm32-wasi]
target: [wasm32-unknown-unknown]
runs-on: ubuntu-latest
steps:
- name: Install rust
Expand All @@ -101,6 +101,33 @@ jobs:
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
run: make check
wasi:
name: WASI
strategy:
fail-fast: false
matrix:
target: [wasm32-wasi]
runs-on: ubuntu-latest
steps:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Checkout
uses: actions/checkout@v3
- name: Install WasmTime
run: |
curl https://wasmtime.dev/install.sh -sSf | bash
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/v4.0.0/wasmtime-v4.0.0-x86_64-linux.tar.xz
tar xvf wasmtime-v4.0.0-x86_64-linux.tar.xz
echo `pwd`/wasmtime-v4.0.0-x86_64-linux >> $GITHUB_PATH
- name: Test
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
run: make test
nightly:
name: Nightly Tests
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ features = [
]

[dev-dependencies]
proptest = "1.0.0"
# Pick a setup for proptest that works with wasi
proptest = { version = "1.0.0", default-features = false, features = ["std", "bit-set", "break-dead-code"] }
regex = "1.4.2"

## These are currently disabled. If you want to play around with the benchmarks
Expand Down
4 changes: 4 additions & 0 deletions scripts/wasmtime-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/..
wasmtime run --env INSTA_WORKSPACE_ROOT=/ --mapdir "/::$(pwd)" -- "$@"
11 changes: 10 additions & 1 deletion src/wasm_term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ pub const DEFAULT_WIDTH: u16 = 80;

#[inline]
pub fn is_a_terminal(_out: &Term) -> bool {
false
#[cfg(target = "wasm32-wasi")]
{
unsafe { libc::isatty(out.as_raw_fd()) != 0 }
}
#[cfg(not(target = "wasm32-wasi"))]
{
false
}
}

#[inline]
pub fn is_a_color_terminal(_out: &Term) -> bool {
// We currently never report color terminals. For discussion see
// the issue in the WASI repo: https://github.com/WebAssembly/WASI/issues/162
false
}

Expand Down