Skip to content

Commit

Permalink
fix(test): only use exactly v0.24.0 geckodriver on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleygwilliams committed Jan 27, 2020
1 parent 846b989 commit 5db509d
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions src/test/webdriver/geckodriver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use target;

// Keep it up to date with each `wasm-pack` release.
// https://github.com/mozilla/geckodriver/releases/latest
const DEFAULT_GECKODRIVER_VERSION: &str = "v0.24.0";
const DEFAULT_GECKODRIVER_VERSION: &str = "v0.26.0";
const DEFAULT_WINDOWS_GECKODRIVER_VERSION: &str = "v0.24.0";

const GECKODRIVER_LAST_UPDATED_STAMP: &str = "geckodriver_last_updated";
const GECKODRIVER_VERSION_STAMP: &str = "geckodriver_version";
Expand All @@ -20,8 +21,18 @@ pub fn get_or_install_geckodriver(
cache: &Cache,
mode: InstallMode,
) -> Result<PathBuf, failure::Error> {
if let Ok(path) = which::which("geckodriver") {
return Ok(path);
// geckodriver Windows binaries >v0.24.0 have an additional
// runtime dependency that we cannot be sure is present on the
// user's machine
//
// https://github.com/mozilla/geckodriver/issues/1617
//
// until this is resolved, always install v0.24.0 on windows
if !target::WINDOWS {
if let Ok(path) = which::which("geckodriver") {
log::info!("[geckodriver] Found geckodriver at {:?}", path);
return Ok(path);
}
}
install_geckodriver(cache, mode.install_permitted())
}
Expand Down Expand Up @@ -78,26 +89,37 @@ fn get_geckodriver_url(target: &str, ext: &str) -> String {
.and_then(save_geckodriver_version)
};

let geckodriver_version = match stamps::read_stamps_file_to_json() {
Ok(json) => {
if should_load_geckodriver_version_from_stamp(&json) {
stamps::get_stamp_value(GECKODRIVER_VERSION_STAMP, &json)
} else {
fetch_and_save_version()
let geckodriver_version = if target::WINDOWS {
log::info!(
"[geckodriver] Windows detected, holding geckodriver version to {}",
DEFAULT_WINDOWS_GECKODRIVER_VERSION
);
DEFAULT_WINDOWS_GECKODRIVER_VERSION.to_owned()
} else {
log::info!("[geckodriver] Looking up latest version of geckodriver...");
match stamps::read_stamps_file_to_json() {
Ok(json) => {
if should_load_geckodriver_version_from_stamp(&json) {
stamps::get_stamp_value(GECKODRIVER_VERSION_STAMP, &json)
} else {
fetch_and_save_version()
}
}
Err(_) => fetch_and_save_version(),
}
Err(_) => fetch_and_save_version(),
}
.unwrap_or_else(|error| {
log::warn!(
"Cannot load or fetch geckodriver's latest version data, \
the default version {} will be used. Error: {}",
DEFAULT_GECKODRIVER_VERSION,
error
);
DEFAULT_GECKODRIVER_VERSION.to_owned()
});
assemble_geckodriver_url(&geckodriver_version, target, ext)
.unwrap_or_else(|error| {
log::warn!(
"[geckodriver] Cannot load or fetch geckodriver's latest version data, \
the default version {} will be used. Error: {}",
DEFAULT_GECKODRIVER_VERSION,
error
);
DEFAULT_GECKODRIVER_VERSION.to_owned()
})
};
let url = assemble_geckodriver_url(&geckodriver_version, target, ext);
log::info!("[geckodriver] Fetching geckodriver at {}", url);
url
}

// ------ `get_geckodriver_url` helpers ------
Expand Down

0 comments on commit 5db509d

Please sign in to comment.