Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): only use exactly v0.24.0 geckodriver on windows #774

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
ashleygwilliams marked this conversation as resolved.
Show resolved Hide resolved
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