|
|
|
@ -176,3 +176,76 @@ fn the_headless_flag_requires_a_browser() { |
|
|
|
|
"running headless tests in node doesn't make sense" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn complains_about_missing_wasm_bindgen_test_dependency() { |
|
|
|
|
let fixture = fixture::Fixture::new(); |
|
|
|
|
fixture |
|
|
|
|
.readme() |
|
|
|
|
.file( |
|
|
|
|
"Cargo.toml", |
|
|
|
|
r#" |
|
|
|
|
[package] |
|
|
|
|
authors = ["The wasm-pack developers"] |
|
|
|
|
description = "so awesome rust+wasm package" |
|
|
|
|
license = "WTFPL" |
|
|
|
|
name = "missing-wbg-test" |
|
|
|
|
repository = "https://github.com/rustwasm/wasm-pack.git" |
|
|
|
|
version = "0.1.0" |
|
|
|
|
|
|
|
|
|
[lib] |
|
|
|
|
crate-type = ["cdylib"] |
|
|
|
|
|
|
|
|
|
[dependencies] |
|
|
|
|
wasm-bindgen = "=0.2.21" |
|
|
|
|
|
|
|
|
|
[dev-dependencies] |
|
|
|
|
# no wasm-bindgen-test dep here! |
|
|
|
|
"#, |
|
|
|
|
).hello_world_src_lib() |
|
|
|
|
.install_local_wasm_bindgen(); |
|
|
|
|
|
|
|
|
|
let cmd = Command::Test(test::TestOptions { |
|
|
|
|
path: Some(fixture.path.clone()), |
|
|
|
|
node: true, |
|
|
|
|
mode: build::BuildMode::Noinstall, |
|
|
|
|
..Default::default() |
|
|
|
|
}); |
|
|
|
|
let logger = logger::new(&cmd, 3).unwrap(); |
|
|
|
|
|
|
|
|
|
let result = command::run_wasm_pack(cmd, &logger); |
|
|
|
|
assert!( |
|
|
|
|
result.is_err(), |
|
|
|
|
"running tests without wasm-bindgen-test won't work" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Test that the error message has two occurrences of "wasm-bindgen-test" in
|
|
|
|
|
// it. I am surprised to learn there is no `str` method to count
|
|
|
|
|
// occurrences, so we find the first and the last and assert that they
|
|
|
|
|
// aren't the same occurrence.
|
|
|
|
|
//
|
|
|
|
|
// This should protect against regresstions where we said:
|
|
|
|
|
//
|
|
|
|
|
// Ensure that you have "wasm-bindgen" as a dependency in your Cargo.toml file:
|
|
|
|
|
// [dev-dependencies]
|
|
|
|
|
// wasm-bindgen-test = "0.2"
|
|
|
|
|
//
|
|
|
|
|
// instead of
|
|
|
|
|
//
|
|
|
|
|
// Ensure that you have "wasm-bindgen-test" as a dependency in your Cargo.toml file:
|
|
|
|
|
// [dev-dependencies]
|
|
|
|
|
// wasm-bindgen-test = "0.2"
|
|
|
|
|
//
|
|
|
|
|
// Note that the whole reason we are doing this string manipulation instead
|
|
|
|
|
// of just doing `assert_eq!` is because the first occurrence of the
|
|
|
|
|
// dependency name is bolded with terminal escape codes and if I try to pipe
|
|
|
|
|
// the output to a text file, then the escape codes go away, so I can't
|
|
|
|
|
// figure out which exact escape codes are even used here.
|
|
|
|
|
|
|
|
|
|
let err_msg = result.unwrap_err().to_string(); |
|
|
|
|
let first = err_msg.find("wasm-bindgen-test"); |
|
|
|
|
assert!(first.is_some()); |
|
|
|
|
let second = err_msg.rfind("wasm-bindgen-test"); |
|
|
|
|
assert!(second.is_some()); |
|
|
|
|
assert_ne!(first, second, "should have found two occurrences"); |
|
|
|
|
} |
|
|
|
|