Skip to content

Commit

Permalink
Fix feature-gating of test-programs (#612)
Browse files Browse the repository at this point in the history
* Fix feature-gating of test-programs

This commit fixes bugs in enabling feature-gating of `test-programs`
which was introduced in #600. It turns out, #600 accidentally
disabled `test-programs` from ever running, and this commit fixes
that.

* Fix the CI
  • Loading branch information
Jakub Konka authored Nov 21, 2019
1 parent eb85380 commit bbe2a79
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- run: cargo fetch

# Build and test all features except for lightbeam
- run: cargo test --features test-programs --all --exclude lightbeam --exclude wasmtime-wasi-c --exclude wasmtime-py -- --nocapture
- run: cargo test --features test_programs --all --exclude lightbeam --exclude wasmtime-wasi-c --exclude wasmtime-py -- --nocapture
env:
RUST_BACKTRACE: 1

Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
- run: $CENTOS cargo build --release --manifest-path crates/api/Cargo.toml
shell: bash
# Test what we just built
- run: $CENTOS cargo test --features test-programs --release --all --exclude lightbeam --exclude wasmtime-wasi-c --exclude wasmtime-py --exclude wasmtime
- run: $CENTOS cargo test --features test_programs --release --all --exclude lightbeam --exclude wasmtime-wasi-c --exclude wasmtime-py --exclude wasmtime
shell: bash
env:
RUST_BACKTRACE: 1
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ wat = "1.0.2"
libc = "0.2.60"
rayon = "1.1"
wasm-webidl-bindings = "0.6"

[dev-dependencies]
more-asserts = "0.2.1"
# This feature requires the wasm32-wasi target be installed. It enables
# wasm32-wasi integration tests. To enable, run
# `cargo test --features test-programs`.
test-programs = { path = "crates/test-programs", optional = true }
test-programs = { path = "crates/test-programs" }

[build-dependencies]
anyhow = "1.0.19"
Expand All @@ -63,6 +65,7 @@ lightbeam = [
"wasmtime-wast/lightbeam"
]
wasi-c = ["wasmtime-wasi-c"]
test_programs = ["test-programs/test_programs"]

[badges]
maintenance = { status = "actively-developed" }
3 changes: 3 additions & 0 deletions crates/test-programs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ tempfile = "3.1.0"
os_pipe = "0.9"
anyhow = "1.0.19"
wat = "1.0.2"

[features]
test_programs = []
6 changes: 3 additions & 3 deletions crates/test-programs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
//! to automatically run the files in parallel.

fn main() {
#[cfg(features = "test-programs")]
#[cfg(feature = "test_programs")]
wasi_tests::build_and_generate_tests()
}

#[cfg(features = "test-programs")]
#[cfg(feature = "test_programs")]
mod wasi_tests {
use std::env;
use std::fs::{read_dir, DirEntry, File};
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

fn build_and_generate_tests() {
pub(super) fn build_and_generate_tests() {
// Validate if any of test sources are present and if they changed
// This should always work since there is no submodule to init anymore
let bin_tests = std::fs::read_dir("wasi-tests/src/bin").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/test-programs/tests/wasm_tests/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(features = "test-programs")]
#![cfg(feature = "test_programs")]
mod runtime;
mod utils;

Expand Down
4 changes: 2 additions & 2 deletions crates/wasi-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ rustup target add wasm32-wasi
[rustup]: https://rustup.rs

Now, you should be able to run the integration testsuite by running `cargo test` on the
`test-programs` package:
`test-programs` package with `test_programs` feature enabled:

```
cargo test --package test-programs
cargo test --features test_programs --package test-programs
```

## Third-Party Code
Expand Down

0 comments on commit bbe2a79

Please sign in to comment.