Skip to content

Commit

Permalink
wasm: Update testing framework
Browse files Browse the repository at this point in the history
Add back the "test-in-browser" feature. This makes it easier to manage
a single file containing all of the test code.

Signed-off-by: Joe Richey <joerichey@google.com>
  • Loading branch information
josephlr committed May 29, 2020
1 parent eacffd5 commit 11b4f9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,14 @@ jobs:
script:
- cargo test --target wasm32-wasi
# stdweb (wasm32-unknown-unknown) tests (Node, Chrome)
- cargo web test --package stdweb-getrandom
- cargo web test --package stdweb-getrandom --nodejs
- cargo web test --features js --nodejs
- cargo web test --features js
# wasm-bindgen (wasm32-unknown-unknown) tests (Node, Firefox, Chrome)
- cargo test --package wasm-bindgen-getrandom
--target wasm32-unknown-unknown --test node
- cargo test --target wasm32-unknown-unknown --features js
- GECKODRIVER=$HOME/geckodriver
cargo test --package wasm-bindgen-getrandom
--target wasm32-unknown-unknown --test web
cargo test --target wasm32-unknown-unknown --features js,test-in-browser
- CHROMEDRIVER=$HOME/chromedriver
cargo test --package wasm-bindgen-getrandom
--target wasm32-unknown-unknown --test web
cargo test --target wasm32-unknown-unknown --features js,test-in-browser

- name: "WASM via Emscripten"
rust: stable
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@ custom = []
# Unstable feature to support being a libstd dependency
rustc-dep-of-std = ["compiler_builtins", "core"]

# Test/wasm-bindgen only feature to run tests in a browser
test-in-browser = []

[package.metadata.docs.rs]
features = ["std", "custom"]
10 changes: 7 additions & 3 deletions src/test_common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Both getrandom and test can be renamed by the parent module.
// Allow getrandom to be renamed by the parent module.
use super::getrandom;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
use super::test;

#[cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[cfg(feature = "test-in-browser")]
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);

#[test]
fn test_zero() {
Expand Down

0 comments on commit 11b4f9e

Please sign in to comment.