mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-05-04 18:12:16 +00:00
Add env vars to filter wasm-bindgen-test-runner
tests
This is intended to handle #1458 and #822. These issues stem from behavior where: wasm-pack test --node will actually run both Node.js and browser tests! Two new env vars are read here, `WASM_BINDGEN_TEST_ONLY_{NODE,WEB}`, which control which tests are executed by `wasm-bindgen-test-runner`. The intention is that these will be set by `wasm-pack` to configure which tests are run, and if test suites are skipped due to the env vars we'll print an informational message indicating how they can be run. Closes #822 Closes #1458
This commit is contained in:
parent
18746ecf4a
commit
79f370deef
@ -103,6 +103,30 @@ fn rmain() -> Result<(), Error> {
|
|||||||
let headless = env::var("NO_HEADLESS").is_err();
|
let headless = env::var("NO_HEADLESS").is_err();
|
||||||
let debug = env::var("WASM_BINDGEN_NO_DEBUG").is_err();
|
let debug = env::var("WASM_BINDGEN_NO_DEBUG").is_err();
|
||||||
|
|
||||||
|
// Gracefully handle requests to execute only node or only web tests.
|
||||||
|
if env::var_os("WASM_BINDGEN_TEST_ONLY_NODE").is_some() {
|
||||||
|
if !node {
|
||||||
|
println!("this test suite is only configured to run in a browser, \
|
||||||
|
but we're only testing node.js tests so skipping");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if env::var_os("WASM_BINDGEN_TEST_ONLY_WEB").is_some() {
|
||||||
|
if node {
|
||||||
|
println!("\
|
||||||
|
This test suite is only configured to run in node.js, but we're only running
|
||||||
|
browser tests so skipping. If you'd like to run the tests in a browser
|
||||||
|
include this in your crate when testing:
|
||||||
|
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
You'll likely want to put that in a `#[cfg(test)]` module or at the top of an
|
||||||
|
integration test.\
|
||||||
|
");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Make the generated bindings available for the tests to execute against.
|
// Make the generated bindings available for the tests to execute against.
|
||||||
shell.status("Executing bindgen...");
|
shell.status("Executing bindgen...");
|
||||||
let mut b = Bindgen::new();
|
let mut b = Bindgen::new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user