master
Nick Fitzgerald 7 years ago
parent 8e6cc1fc21
commit e1c8ca825d
  1. 6
      src/binaries.rs
  2. 6
      src/bindgen.rs
  3. 6
      src/command/test.rs
  4. 3
      src/lockfile.rs
  5. 3
      src/manifest/mod.rs
  6. 6
      src/test/webdriver.rs
  7. 3
      tests/all/build.rs
  8. 18
      tests/all/lockfile.rs
  9. 3
      tests/all/manifest.rs
  10. 6
      tests/all/test.rs
  11. 21
      tests/all/utils/fixture.rs

@ -78,7 +78,8 @@ pub fn bin_path(log: &Logger, crate_path: &Path, bin: &str) -> Option<PathBuf> {
let p = p.canonicalize().unwrap_or(p); let p = p.canonicalize().unwrap_or(p);
debug!(log, "Using {} binary at {}", bin, p.display()); debug!(log, "Using {} binary at {}", bin, p.display());
p p
}).or_else(|| { })
.or_else(|| {
debug!(log, "Could not find {} binary.", bin); debug!(log, "Could not find {} binary.", bin);
None None
}) })
@ -124,7 +125,8 @@ fn curl(url: &str) -> Result<Vec<u8>, failure::Error> {
Err(Error::http(&format!( Err(Error::http(&format!(
"received a bad HTTP status code ({}) when requesting {}", "received a bad HTTP status code ({}) when requesting {}",
status_code, url status_code, url
)).into()) ))
.into())
} }
} }

@ -184,8 +184,10 @@ fn wasm_bindgen_version_check(bindgen_path: &PathBuf, dep_version: &str, log: &L
dep_version dep_version
); );
v == dep_version v == dep_version
}).unwrap_or(false) })
}).unwrap_or(false) .unwrap_or(false)
})
.unwrap_or(false)
} }
/// Return a `PathBuf` containing the path to either the local wasm-bindgen /// Return a `PathBuf` containing the path to either the local wasm-bindgen

@ -126,14 +126,16 @@ impl Test {
if !node && !any_browser { if !node && !any_browser {
return Error::crate_config( return Error::crate_config(
"Must specify at least one of `--node`, `--chrome`, `--firefox`, or `--safari`", "Must specify at least one of `--node`, `--chrome`, `--firefox`, or `--safari`",
).map(|_| unreachable!()); )
.map(|_| unreachable!());
} }
if headless && !any_browser { if headless && !any_browser {
return Error::crate_config( return Error::crate_config(
"The `--headless` flag only applies to browser tests. Node does not provide a UI, \ "The `--headless` flag only applies to browser tests. Node does not provide a UI, \
so it doesn't make sense to talk about a headless version of Node tests.", so it doesn't make sense to talk about a headless version of Node tests.",
).map(|_| unreachable!()); )
.map(|_| unreachable!());
} }
Ok(Test { Ok(Test {

@ -69,7 +69,8 @@ fn get_lockfile_path(crate_path: &Path) -> Result<PathBuf, Error> {
let crate_root = cargo_metadata::metadata(Some(&manifest)) let crate_root = cargo_metadata::metadata(Some(&manifest))
.map_err(|_| Error::CrateConfig { .map_err(|_| Error::CrateConfig {
message: String::from("Error while processing crate metadata"), message: String::from("Error while processing crate metadata"),
})?.workspace_root; })?
.workspace_root;
// Check that a lock file can be found in the directory. Return an error // Check that a lock file can be found in the directory. Return an error
// if it cannot, otherwise return the path buffer. // if it cannot, otherwise return the path buffer.
let lockfile_path = Path::new(&crate_root).join("Cargo.lock"); let lockfile_path = Path::new(&crate_root).join("Cargo.lock");

@ -81,7 +81,8 @@ fn read_cargo_toml(path: &Path) -> Result<CargoManifest, Error> {
return Error::crate_config(&format!( return Error::crate_config(&format!(
"Crate directory is missing a `Cargo.toml` file; is `{}` the wrong directory?", "Crate directory is missing a `Cargo.toml` file; is `{}` the wrong directory?",
path.display() path.display()
)).map(|_| unreachable!()); ))
.map(|_| unreachable!());
} }
let mut cargo_file = File::open(manifest_path)?; let mut cargo_file = File::open(manifest_path)?;
let mut cargo_contents = String::new(); let mut cargo_contents = String::new();

@ -24,7 +24,8 @@ pub fn get_or_install_chromedriver(
"No crate-local `chromedriver` binary found, and could not find a global \ "No crate-local `chromedriver` binary found, and could not find a global \
`chromedriver` on the `$PATH`. Not installing `chromedriver` because of noinstall \ `chromedriver` on the `$PATH`. Not installing `chromedriver` because of noinstall \
mode.", mode.",
).map(|_| unreachable!()), )
.map(|_| unreachable!()),
} }
} }
@ -74,7 +75,8 @@ pub fn get_or_install_geckodriver(
(BuildMode::Noinstall, None) => Error::crate_config( (BuildMode::Noinstall, None) => Error::crate_config(
"No crate-local `geckodriver` binary found, and could not find a global `geckodriver` \ "No crate-local `geckodriver` binary found, and could not find a global `geckodriver` \
on the `$PATH`. Not installing `geckodriver` because of noinstall mode.", on the `$PATH`. Not installing `geckodriver` because of noinstall mode.",
).map(|_| unreachable!()), )
.map(|_| unreachable!()),
} }
} }

@ -9,7 +9,8 @@ fn build_in_non_crate_directory_doesnt_panic() {
"wasm-pack", "wasm-pack",
"build", "build",
&fixture.path.display().to_string(), &fixture.path.display().to_string(),
]).unwrap(); ])
.unwrap();
let logger = logger::new(&cli.cmd, cli.verbosity).unwrap(); let logger = logger::new(&cli.cmd, cli.verbosity).unwrap();
let result = command::run_wasm_pack(cli.cmd, &logger); let result = command::run_wasm_pack(cli.cmd, &logger);
assert!( assert!(

@ -27,7 +27,8 @@ fn it_gets_wasm_bindgen_version_in_crate_inside_workspace() {
[workspace] [workspace]
members = ["./blah"] members = ["./blah"]
"#, "#,
).file( )
.file(
"blah/Cargo.toml", "blah/Cargo.toml",
r#" r#"
[package] [package]
@ -44,7 +45,8 @@ fn it_gets_wasm_bindgen_version_in_crate_inside_workspace() {
[dependencies] [dependencies]
wasm-bindgen = "=0.2.21" wasm-bindgen = "=0.2.21"
"#, "#,
).file( )
.file(
"blah/src/lib.rs", "blah/src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -69,7 +71,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[workspace] [workspace]
members = ["./parent", "./child"] members = ["./parent", "./child"]
"#, "#,
).file( )
.file(
"child/Cargo.toml", "child/Cargo.toml",
r#" r#"
[package] [package]
@ -86,7 +89,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[dependencies] [dependencies]
wasm-bindgen = "=0.2.21" wasm-bindgen = "=0.2.21"
"#, "#,
).file( )
.file(
"child/src/lib.rs", "child/src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -95,7 +99,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
#[wasm_bindgen] #[wasm_bindgen]
pub fn hello() -> u32 { 42 } pub fn hello() -> u32 { 42 }
"#, "#,
).file( )
.file(
"parent/Cargo.toml", "parent/Cargo.toml",
r#" r#"
[package] [package]
@ -109,7 +114,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
"#, "#,
).file( )
.file(
"parent/src/lib.rs", "parent/src/lib.rs",
r#" r#"
// Just re-export all of `child`. // Just re-export all of `child`.

@ -129,7 +129,8 @@ fn it_creates_a_package_json_provided_path_with_scope() {
false, false,
"", "",
&step &step
).is_ok() )
.is_ok()
); );
let package_json_path = &fixture.path.join("pkg").join("package.json"); let package_json_path = &fixture.path.join("pkg").join("package.json");
assert!(fs::metadata(package_json_path).is_ok()); assert!(fs::metadata(package_json_path).is_ok());

@ -122,7 +122,8 @@ fn it_can_find_a_webdriver_on_path() {
geckodriver_dir geckodriver_dir
.path() .path()
.join(local_geckodriver.file_name().unwrap()), .join(local_geckodriver.file_name().unwrap()),
).unwrap(); )
.unwrap();
fs::remove_file(&local_geckodriver).unwrap(); fs::remove_file(&local_geckodriver).unwrap();
let mut paths: Vec<_> = env::split_paths(&env::var("PATH").unwrap()).collect(); let mut paths: Vec<_> = env::split_paths(&env::var("PATH").unwrap()).collect();
@ -202,7 +203,8 @@ fn complains_about_missing_wasm_bindgen_test_dependency() {
[dev-dependencies] [dev-dependencies]
# no wasm-bindgen-test dep here! # no wasm-bindgen-test dep here!
"#, "#,
).hello_world_src_lib() )
.hello_world_src_lib()
.install_local_wasm_bindgen(); .install_local_wasm_bindgen();
let cmd = Command::Test(test::TestOptions { let cmd = Command::Test(test::TestOptions {

@ -152,7 +152,8 @@ impl Fixture {
wasm_pack::bindgen::download_prebuilt_wasm_bindgen(&tests, WASM_BINDGEN_VERSION) wasm_pack::bindgen::download_prebuilt_wasm_bindgen(&tests, WASM_BINDGEN_VERSION)
.or_else(|_| { .or_else(|_| {
wasm_pack::bindgen::cargo_install_wasm_bindgen(&tests, WASM_BINDGEN_VERSION) wasm_pack::bindgen::cargo_install_wasm_bindgen(&tests, WASM_BINDGEN_VERSION)
}).unwrap(); })
.unwrap();
}); });
assert!(shared_wasm_bindgen.is_file()); assert!(shared_wasm_bindgen.is_file());
@ -163,12 +164,14 @@ impl Fixture {
hard_link_or_copy( hard_link_or_copy(
&shared_wasm_bindgen, &shared_wasm_bindgen,
wasm_pack::binaries::local_bin_path(&self.path, "wasm-bindgen"), wasm_pack::binaries::local_bin_path(&self.path, "wasm-bindgen"),
).expect("could not copy `wasm-bindgen` to fixture directory"); )
.expect("could not copy `wasm-bindgen` to fixture directory");
hard_link_or_copy( hard_link_or_copy(
&shared_wasm_bindgen_test_runner, &shared_wasm_bindgen_test_runner,
wasm_pack::binaries::local_bin_path(&self.path, "wasm-bindgen-test-runner"), wasm_pack::binaries::local_bin_path(&self.path, "wasm-bindgen-test-runner"),
).expect("could not copy `wasm-bindgen-test` to fixture directory"); )
.expect("could not copy `wasm-bindgen-test` to fixture directory");
self self
} }
@ -202,7 +205,8 @@ impl Fixture {
hard_link_or_copy( hard_link_or_copy(
&geckodriver, &geckodriver,
wasm_pack::binaries::local_bin_path(&self.path, "geckodriver"), wasm_pack::binaries::local_bin_path(&self.path, "geckodriver"),
).expect("could not copy `geckodriver` to fixture directory"); )
.expect("could not copy `geckodriver` to fixture directory");
self self
} }
@ -236,7 +240,8 @@ impl Fixture {
hard_link_or_copy( hard_link_or_copy(
&chromedriver, &chromedriver,
wasm_pack::binaries::local_bin_path(&self.path, "chromedriver"), wasm_pack::binaries::local_bin_path(&self.path, "chromedriver"),
).expect("could not copy `chromedriver` to fixture directory"); )
.expect("could not copy `chromedriver` to fixture directory");
self self
} }
@ -375,7 +380,8 @@ pub fn wbg_test_diff_versions() -> Fixture {
# wasm-bindgen-test at 0.2.19, and everything should still work. # wasm-bindgen-test at 0.2.19, and everything should still work.
wasm-bindgen-test = "0.2.19" wasm-bindgen-test = "0.2.19"
"#, "#,
).file( )
.file(
"src/lib.rs", "src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -384,7 +390,8 @@ pub fn wbg_test_diff_versions() -> Fixture {
#[wasm_bindgen] #[wasm_bindgen]
pub fn one() -> u32 { 1 } pub fn one() -> u32 { 1 }
"#, "#,
).file( )
.file(
"tests/node.rs", "tests/node.rs",
r#" r#"
extern crate wbg_test_diff_versions; extern crate wbg_test_diff_versions;

Loading…
Cancel
Save