Add back building tests

master
Chinedu Francis Nwafili 6 years ago
parent f7ad0e7c5a
commit 879e3aa7a6
No known key found for this signature in database
GPG Key ID: 3C85D8F6538D8AD9
  1. 17
      src/build.rs
  2. 15
      src/command/test.rs

@ -25,7 +25,7 @@ pub fn check_rustc_version(step: &Step) -> Result<String, Error> {
} else {
Ok(mv.to_string())
}
},
}
None => bail!("We can't figure out what your Rust version is- which means you might not have Rust installed. Please install Rust version 1.30.0 or higher."),
}
}
@ -93,3 +93,18 @@ pub fn cargo_build_wasm(
child::run(cmd, "cargo build").context("Compiling your crate to WebAssembly failed")?;
Ok(())
}
/// Run `cargo build --tests` targetting `wasm32-unknown-unknown`.
///
/// This generates the `Cargo.lock` file that we use in order to know which version of
/// wasm-bindgen-cli to use when running tests.
pub fn cargo_build_wasm_tests(path: &Path, debug: bool) -> Result<(), Error> {
let mut cmd = Command::new("cargo");
cmd.current_dir(path).arg("build").arg("--tests");
if !debug {
cmd.arg("--release");
}
cmd.arg("--target").arg("wasm32-unknown-unknown");
child::run(cmd, "cargo build").context("Compilation of your program failed")?;
Ok(())
}

@ -197,6 +197,7 @@ impl Test {
BuildMode::Normal => steps![
step_check_rustc_version,
step_add_wasm_target,
step_build_tests,
step_install_wasm_bindgen,
step_test_node if self.node,
step_get_chromedriver if self.chrome && self.chromedriver.is_none(),
@ -208,6 +209,7 @@ impl Test {
],
BuildMode::Force => steps![
step_add_wasm_target,
step_build_tests,
step_install_wasm_bindgen,
step_test_node if self.node,
step_get_chromedriver if self.chrome && self.chromedriver.is_none(),
@ -218,6 +220,7 @@ impl Test {
step_test_safari if self.safari,
],
BuildMode::Noinstall => steps![
step_build_tests,
step_install_wasm_bindgen,
step_test_node if self.node,
step_get_chromedriver if self.chrome && self.chromedriver.is_none(),
@ -244,6 +247,18 @@ impl Test {
Ok(())
}
fn step_build_tests(&mut self, step: &Step) -> Result<(), Error> {
info!("Compiling tests to wasm...");
let msg = format!("{}Compiling tests to WASM...", emoji::CYCLONE);
PBAR.step(step, &msg);
build::cargo_build_wasm_tests(&self.crate_path, !self.release)?;
info!("Finished compiling tests to wasm.");
Ok(())
}
fn step_install_wasm_bindgen(&mut self, step: &Step) -> Result<(), Error> {
info!("Identifying wasm-bindgen dependency...");
let lockfile = Lockfile::new(&self.crate_data)?;

Loading…
Cancel
Save