Skip to content

[rust] Test Selenium Manager on Linux arm64 #16045

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
include:
- os: macos
- os: ubuntu
- os: ubuntu-24.04-arm
- os: windows
with:
name: Tests (${{ matrix.os }})
Expand Down
2 changes: 2 additions & 0 deletions rust/src/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ impl SeleniumManager for ChromeManager {
} else {
"mac64"
}
} else if LINUX.is(os) && ARM64.is(arch) {
return Err(anyhow!("Linux arm64 is not supported yet by Google Chrome. Please try another browser."));
} else {
"linux64"
};
Expand Down
3 changes: 3 additions & 0 deletions rust/src/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::{
DASH_DASH_VERSION, DEV, ENV_PROGRAM_FILES_X86, NIGHTLY, OFFLINE_REQUEST_ERR_MSG, REG_PV_ARG,
REG_VERSION_ARG, STABLE,
};
use anyhow::anyhow;
use anyhow::Error;
use reqwest::Client;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -288,6 +289,8 @@ impl SeleniumManager for EdgeManager {
} else {
"mac64"
}
} else if LINUX.is(os) && ARM64.is(arch) {
return Err(anyhow!("Linux arm64 is not supported yet by Microsoft Edge. Please try another browser."));
} else {
"linux64"
};
Expand Down
39 changes: 23 additions & 16 deletions rust/tests/browser_download_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use crate::common::{assert_browser, assert_driver, get_selenium_manager};

use rstest::rstest;
use std::env::consts::ARCH;
use std::env::consts::OS;

mod common;
Expand All @@ -27,23 +28,27 @@ mod common;
#[case("firefox")]
#[case("edge")]
fn browser_latest_download_test(#[case] browser: String) {
if !browser.eq("edge") || !OS.eq("windows") {
let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
&browser,
"--force-browser-download",
"--output",
"json",
"--debug",
])
.assert()
.success()
.code(0);

assert_driver(&mut cmd);
assert_browser(&mut cmd);
if browser.eq("edge") && OS.eq("windows") {
return;
} else if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
return;
}

let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
&browser,
"--force-browser-download",
"--output",
"json",
"--debug",
])
.assert()
.success()
.code(0);

assert_driver(&mut cmd);
assert_browser(&mut cmd);
}

#[rstest]
Expand All @@ -59,6 +64,8 @@ fn browser_latest_download_test(#[case] browser: String) {
fn browser_version_download_test(#[case] browser: String, #[case] browser_version: String) {
if OS.eq("windows") && browser.eq("edge") {
println!("Skipping Edge download test on Windows since the installation requires admin privileges");
} else if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
println!("Skipping non-Firefox download test on Linux arm64 since no other browsers are supported yet");
} else {
let mut cmd = get_selenium_manager();
cmd.args([
Expand Down
9 changes: 9 additions & 0 deletions rust/tests/browser_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::common::{assert_output, get_selenium_manager, get_stdout};

use exitcode::DATAERR;
use rstest::rstest;
use std::env::consts::ARCH;
use std::env::consts::OS;
use std::path::Path;

Expand All @@ -40,6 +41,10 @@ fn browser_version_test(
#[case] browser_version: String,
#[case] driver_version: String,
) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
return;
}

let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
Expand Down Expand Up @@ -78,6 +83,10 @@ fn wrong_parameters_test(
#[case] driver_version: String,
#[case] error_code: i32,
) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
return
}

let mut cmd = get_selenium_manager();
let result = cmd
.args([
Expand Down
1 change: 1 addition & 0 deletions rust/tests/cache_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::path::Path;

mod common;

#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
#[rstest]
#[case("../tmp")]
#[case("../áèîö")]
Expand Down
6 changes: 6 additions & 0 deletions rust/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use selenium_manager::logger::JsonOutput;
use selenium_manager::shell;
use selenium_manager::shell::run_shell_command_by_os;
use std::borrow::BorrowMut;
use std::env::consts::ARCH;
use std::env::consts::OS;
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -119,3 +120,8 @@ pub fn assert_output(
.contains(&error_code.to_string()));
}
}

#[allow(dead_code)]
pub fn is_linux_arm64() -> bool {
OS == "linux" && ARCH == "aarch64"
}
5 changes: 5 additions & 0 deletions rust/tests/config_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use crate::common::{assert_browser, assert_driver, get_selenium_manager, get_std

use rstest::rstest;

use std::env::consts::ARCH;
use std::env::consts::OS;
use std::fs::File;
use std::io::{BufWriter, Write};
use tempfile::Builder;
Expand All @@ -30,6 +32,9 @@ mod common;
#[case("firefox")]
#[case("edge")]
fn config_test(#[case] browser_name: String) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser_name.eq("firefox") {
return
}
let tmp_dir = Builder::new().prefix("sm-config-test").tempdir().unwrap();
let config_path = tmp_dir.path().join("se-config.toml");
let config_file = File::create(config_path.as_path()).unwrap();
Expand Down
5 changes: 5 additions & 0 deletions rust/tests/exec_driver_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use crate::common::{assert_browser, assert_driver, exec_driver, get_selenium_manager};

use rstest::rstest;
use std::env::consts::ARCH;
use std::env::consts::OS;

mod common;
Expand All @@ -28,6 +29,10 @@ mod common;
#[case("firefox", "geckodriver")]
#[case("iexplorer", "IEDriverServer")]
fn exec_driver_test(#[case] browser_name: String, #[case] driver_name: String) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser_name.eq("firefox") {
return
}

let mut cmd = get_selenium_manager();
cmd.args(["--browser", &browser_name, "--output", "json"])
.assert()
Expand Down
4 changes: 2 additions & 2 deletions rust/tests/mirror_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use crate::common::{assert_driver, get_selenium_manager};
use crate::common::{assert_driver, is_linux_arm64, get_selenium_manager};

mod common;

Expand All @@ -24,7 +24,7 @@ fn mirror_test() {
let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
"chrome",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--driver-mirror-url",
"https://registry.npmmirror.com/-/binary/chromedriver/",
"--browser-version",
Expand Down
15 changes: 10 additions & 5 deletions rust/tests/offline_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@
// specific language governing permissions and limitations
// under the License.

use crate::common::{get_selenium_manager, get_stdout};
use crate::common::{get_selenium_manager, get_stdout, is_linux_arm64};

mod common;

#[test]
fn offline_test() {
let mut cmd = get_selenium_manager();
cmd.args(["--debug", "--browser", "chrome", "--offline"])
.assert()
.success()
.code(0);
cmd.args([
"--debug",
"--browser",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--offline"
])
.assert()
.success()
.code(0);

let stdout = get_stdout(&mut cmd);

Expand Down
41 changes: 28 additions & 13 deletions rust/tests/output_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use crate::common::{get_selenium_manager, get_stderr, get_stdout};
use crate::common::{get_selenium_manager, get_stderr, get_stdout, is_linux_arm64};

use selenium_manager::logger::{JsonOutput, MinimalJson, DRIVER_PATH};
use std::path::Path;
Expand All @@ -25,10 +25,15 @@ mod common;
#[test]
fn json_output_test() {
let mut cmd = get_selenium_manager();
cmd.args(["--browser", "chrome", "--output", "json"])
.assert()
.success()
.code(0);
cmd.args([
"--browser",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--output",
"json"
])
.assert()
.success()
.code(0);

let stdout = get_stdout(&mut cmd);

Expand All @@ -45,10 +50,15 @@ fn json_output_test() {
#[test]
fn shell_output_test() {
let mut cmd = get_selenium_manager();
cmd.args(["--browser", "chrome", "--output", "shell"])
.assert()
.success()
.code(0);
cmd.args([
"--browser",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--output",
"shell"
])
.assert()
.success()
.code(0);

let stdout = get_stdout(&mut cmd);
assert!(stdout.contains(DRIVER_PATH));
Expand All @@ -57,10 +67,15 @@ fn shell_output_test() {
#[test]
fn mixed_output_test() {
let mut cmd = get_selenium_manager();
cmd.args(["--browser", "chrome", "--output", "mixed"])
.assert()
.success()
.code(0);
cmd.args([
"--browser",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--output",
"mixed"
])
.assert()
.success()
.code(0);

let stdout = get_stdout(&mut cmd);
let json: MinimalJson = serde_json::from_str(&stdout).unwrap();
Expand Down
14 changes: 10 additions & 4 deletions rust/tests/proxy_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use crate::common::{assert_output, get_selenium_manager};
use crate::common::{assert_output, get_selenium_manager, is_linux_arm64};

use exitcode::DATAERR;

Expand All @@ -28,7 +28,7 @@ async fn wrong_proxy_test() {
.args([
"--debug",
"--browser",
"chrome",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--proxy",
"http://localhost:12345",
])
Expand All @@ -37,11 +37,17 @@ async fn wrong_proxy_test() {

assert_output(&mut cmd, result, vec!["in PATH"], DATAERR);
}

#[test]
fn wrong_protocol_proxy_test() {
let mut cmd = get_selenium_manager();
let result = cmd
.args(["--browser", "chrome", "--proxy", "wrong:://proxy"])
.args([
"--browser",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--proxy",
"wrong:://proxy"
])
.assert()
.try_success();

Expand All @@ -54,7 +60,7 @@ fn wrong_port_proxy_test() {
let result = cmd
.args([
"--browser",
"chrome",
if is_linux_arm64() { "firefox" } else { "chrome" },
"--proxy",
"https:://localhost:1234567",
])
Expand Down
6 changes: 6 additions & 0 deletions rust/tests/stable_browser_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use crate::common::{assert_browser, assert_driver, get_selenium_manager};

use rstest::rstest;
use std::env::consts::ARCH;
use std::env::consts::OS;

mod common;

Expand All @@ -26,6 +28,10 @@ mod common;
#[case("firefox")]
#[case("edge")]
fn stable_browser_test(#[case] browser_name: String) {
if OS.eq("linux") && ARCH.eq("aarch64") && !browser_name.eq("firefox") {
return
}

let mut cmd = get_selenium_manager();
cmd.args([
"--browser",
Expand Down
1 change: 1 addition & 0 deletions rust/tests/webview_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::common::{assert_driver, get_selenium_manager};

mod common;

#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
#[test]
fn webview2_test() {
let mut cmd = get_selenium_manager();
Expand Down