Skip to content

Commit

Permalink
Don't pass through test filter to cargo build.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 committed Sep 26, 2020
1 parent 80400bd commit f583209
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,15 @@ impl Test {
fn step_build_tests(&mut self) -> Result<(), Error> {
info!("Compiling tests to wasm...");

build::cargo_build_wasm_tests(&self.crate_path, !self.release, &self.extra_options)?;
// If the user has run `wasm-pack test -- --features "f1" -- test_name`, then we want to only pass through
// `--features "f1"` to `cargo build`
let extra_options =
if let Some(index) = self.extra_options.iter().position(|arg| arg == "--") {
&self.extra_options[..index]
} else {
&self.extra_options
};
build::cargo_build_wasm_tests(&self.crate_path, !self.release, extra_options)?;

info!("Finished compiling tests to wasm.");
Ok(())
Expand Down
14 changes: 13 additions & 1 deletion tests/all/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,25 @@ fn extra_options_is_passed_to_cargo_when_building_tests() {
fn smoke() {
foo::foo();
}
#[wasm_bindgen_test]
fn fire() {
panic!("This should be filtered from test execution.");
}
"#,
)
.install_local_wasm_bindgen();
let _lock = fixture.lock();
fixture
.wasm_pack()
.args(&["test", "--node", "--", "--no-default-features"])
.args(&[
"test",
"--node",
"--",
"--no-default-features",
"--",
"smoke",
])
.assert()
.success();
}

0 comments on commit f583209

Please sign in to comment.