Skip to content

Commit 5ebfa27

Browse files
authored
Merge pull request #1465 from alexcrichton/only-node-tests
Add env vars to filter `wasm-bindgen-test-runner` tests
2 parents 18746ec + 79f370d commit 5ebfa27

File tree

1 file changed

+24
-0
lines changed
  • crates/cli/src/bin/wasm-bindgen-test-runner

1 file changed

+24
-0
lines changed

crates/cli/src/bin/wasm-bindgen-test-runner/main.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@ fn rmain() -> Result<(), Error> {
103103
let headless = env::var("NO_HEADLESS").is_err();
104104
let debug = env::var("WASM_BINDGEN_NO_DEBUG").is_err();
105105

106+
// Gracefully handle requests to execute only node or only web tests.
107+
if env::var_os("WASM_BINDGEN_TEST_ONLY_NODE").is_some() {
108+
if !node {
109+
println!("this test suite is only configured to run in a browser, \
110+
but we're only testing node.js tests so skipping");
111+
return Ok(());
112+
}
113+
}
114+
if env::var_os("WASM_BINDGEN_TEST_ONLY_WEB").is_some() {
115+
if node {
116+
println!("\
117+
This test suite is only configured to run in node.js, but we're only running
118+
browser tests so skipping. If you'd like to run the tests in a browser
119+
include this in your crate when testing:
120+
121+
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
122+
123+
You'll likely want to put that in a `#[cfg(test)]` module or at the top of an
124+
integration test.\
125+
");
126+
return Ok(());
127+
}
128+
}
129+
106130
// Make the generated bindings available for the tests to execute against.
107131
shell.status("Executing bindgen...");
108132
let mut b = Bindgen::new();

0 commit comments

Comments
 (0)