feat(buildmode): allow --mode force to skip rustc check

master
Ashley Williams 7 years ago
parent d5d3358ff3
commit d3f8264ef7
  1. 11
      src/command/build.rs
  2. 24
      src/command/test.rs
  3. 2
      src/test/webdriver.rs
  4. 24
      tests/all/bindgen.rs
  5. 30
      tests/all/test.rs
  6. 28
      tests/all/webdriver.rs

@ -38,6 +38,8 @@ pub enum BuildMode {
/// Don't install tools like `wasm-bindgen`, just use the global
/// environment's existing versions to do builds.
Noinstall,
/// Skip the rustc version check
Force,
}
impl Default for BuildMode {
@ -52,6 +54,7 @@ impl FromStr for BuildMode {
match s {
"no-install" => Ok(BuildMode::Noinstall),
"normal" => Ok(BuildMode::Normal),
"force" => Ok(BuildMode::Force),
_ => Error::crate_config(&format!("Unknown build mode: {}", s)).map(|_| unreachable!()),
}
}
@ -175,6 +178,13 @@ impl Build {
step_copy_readme,
step_run_wasm_bindgen
],
BuildMode::Force => steps![
step_build_wasm,
step_create_dir,
step_create_json,
step_copy_readme,
step_run_wasm_bindgen
],
}
}
@ -255,6 +265,7 @@ impl Build {
info!(&log, "Installing wasm-bindgen-cli...");
let install_permitted = match self.mode {
BuildMode::Normal => true,
BuildMode::Force => true,
BuildMode::Noinstall => false,
};
bindgen::install_wasm_bindgen(

@ -185,6 +185,7 @@ impl Test {
}
match self.mode {
BuildMode::Normal => steps![
step_check_rustc_version,
step_check_crate_config,
step_add_wasm_target,
step_build_tests,
@ -197,6 +198,18 @@ impl Test {
step_get_safaridriver if self.safari && self.safaridriver.is_none(),
step_test_safari if self.safari,
],
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(),
step_test_chrome if self.chrome,
step_get_geckodriver if self.firefox && self.geckodriver.is_none(),
step_test_firefox if self.firefox,
step_get_safaridriver if self.safari && self.safaridriver.is_none(),
step_test_safari if self.safari,
],
BuildMode::Noinstall => steps![
step_check_crate_config,
step_build_tests,
@ -212,6 +225,13 @@ impl Test {
}
}
fn step_check_rustc_version(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
info!(log, "Checking rustc version...");
let _ = build::check_rustc_version(step)?;
info!(log, "Rustc version is correct.");
Ok(())
}
fn step_check_crate_config(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
info!(log, "Checking crate configuration...");
manifest::check_crate_config(&self.crate_path, step)?;
@ -263,6 +283,10 @@ impl Test {
info!(&log, "Ensuring wasm-bindgen-cli is installed...");
true
}
BuildMode::Force => {
info!(&log, "Ensuring wasm-bindgen-cli is installed...");
true
}
BuildMode::Noinstall => {
info!(&log, "Searching for existing wasm-bindgen-cli install...");
false

@ -19,6 +19,7 @@ pub fn get_or_install_chromedriver(
match (mode, bin_path(log, crate_path, "chromedriver")) {
(_, Some(path)) => Ok(path),
(BuildMode::Normal, None) => install_chromedriver(crate_path),
(BuildMode::Force, None) => install_chromedriver(crate_path),
(BuildMode::Noinstall, None) => Error::crate_config(
"No crate-local `chromedriver` binary found, and could not find a global \
`chromedriver` on the `$PATH`. Not installing `chromedriver` because of noinstall \
@ -69,6 +70,7 @@ pub fn get_or_install_geckodriver(
match (mode, bin_path(log, crate_path, "geckodriver")) {
(_, Some(path)) => Ok(path),
(BuildMode::Normal, None) => install_geckodriver(crate_path),
(BuildMode::Force, None) => install_geckodriver(crate_path),
(BuildMode::Noinstall, None) => Error::crate_config(
"No crate-local `geckodriver` binary found, and could not find a global `geckodriver` \
on the `$PATH`. Not installing `geckodriver` because of noinstall mode.",

@ -2,11 +2,13 @@ use tempfile;
use wasm_pack::bindgen;
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(windows, target_arch = "x86_64"),
))]
#[cfg(
any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(windows, target_arch = "x86_64"),
)
)]
fn can_download_prebuilt_wasm_bindgen() {
use std::env;
let dir = tempfile::TempDir::new().unwrap();
@ -28,11 +30,13 @@ fn can_download_prebuilt_wasm_bindgen() {
}
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(windows, target_arch = "x86_64"),
))]
#[cfg(
any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(windows, target_arch = "x86_64"),
)
)]
fn downloading_prebuilt_wasm_bindgen_handles_http_errors() {
let dir = tempfile::TempDir::new().unwrap();
let bad_version = "0.2.21-some-trailing-version-stuff-that-does-not-exist";

@ -35,12 +35,14 @@ fn it_can_run_tests_with_different_wbg_test_and_wbg_versions() {
}
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86"),
all(target_os = "windows", target_arch = "x86_64")
))]
#[cfg(
any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86"),
all(target_os = "windows", target_arch = "x86_64")
)
)]
fn it_can_run_browser_tests() {
let fixture = fixture::wbg_test_browser();
fixture.install_local_wasm_bindgen();
@ -103,13 +105,15 @@ fn it_can_run_failing_tests() {
}
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86"),
all(target_os = "windows", target_arch = "x86_64")
))]
#[cfg(
any(
all(target_os = "linux", target_arch = "x86"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86"),
all(target_os = "windows", target_arch = "x86_64")
)
)]
fn it_can_find_a_webdriver_on_path() {
let fixture = fixture::wbg_test_browser();
fixture.install_local_wasm_bindgen();

@ -2,24 +2,28 @@ use utils::fixture;
use wasm_pack::test::webdriver;
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86")
))]
#[cfg(
any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86")
)
)]
fn can_install_chromedriver() {
let fixture = fixture::js_hello_world();
assert!(webdriver::install_chromedriver(&fixture.path).is_ok());
}
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86"),
all(target_os = "windows", target_arch = "x86_64")
))]
#[cfg(
any(
all(target_os = "linux", target_arch = "x86"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86"),
all(target_os = "windows", target_arch = "x86_64")
)
)]
fn can_install_geckodriver() {
let fixture = fixture::js_hello_world();
assert!(webdriver::install_geckodriver(&fixture.path).is_ok());

Loading…
Cancel
Save