Skip to content

Commit d1cd431

Browse files
committed
Don't pass through test filter to cargo build.
1 parent 44e826e commit d1cd431

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/command/test.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,15 @@ impl Test {
243243
fn step_build_tests(&mut self) -> Result<(), Error> {
244244
info!("Compiling tests to wasm...");
245245

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

248256
info!("Finished compiling tests to wasm.");
249257
Ok(())

tests/all/test.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,25 @@ fn extra_options_is_passed_to_cargo_when_building_tests() {
380380
fn smoke() {
381381
foo::foo();
382382
}
383+
384+
#[wasm_bindgen_test]
385+
fn fire() {
386+
panic!("This should be filtered from test execution.");
387+
}
383388
"#,
384389
)
385390
.install_local_wasm_bindgen();
386391
let _lock = fixture.lock();
387392
fixture
388393
.wasm_pack()
389-
.args(&["test", "--node", "--", "--no-default-features"])
394+
.args(&[
395+
"test",
396+
"--node",
397+
"--",
398+
"--no-default-features",
399+
"--",
400+
"smoke",
401+
])
390402
.assert()
391403
.success();
392404
}

0 commit comments

Comments
 (0)