Skip to content

Commit 19d72d6

Browse files
committed
[rust] Selenium Manager: Update tests to work with Linux arm64
Currently, only Firefox and Geckodriver have official support for Linux arm64. This commit ensures that the Selenium Manager test suite passes on this platform, by skipping tests on non- Firefox browsers.
1 parent de5e3b2 commit 19d72d6

14 files changed

+114
-40
lines changed

rust/src/chrome.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ impl SeleniumManager for ChromeManager {
383383
} else {
384384
"mac64"
385385
}
386+
} else if LINUX.is(os) && ARM64.is(arch) {
387+
panic!("Linux arm64 is not supported yet by Google Chrome. Please try another browser.")
386388
} else {
387389
"linux64"
388390
};
@@ -448,6 +450,8 @@ impl SeleniumManager for ChromeManager {
448450
} else {
449451
"mac-x64"
450452
}
453+
} else if LINUX.is(os) && ARM64.is(arch) {
454+
panic!("Linux arm64 is not supported yet by Google Chrome. Please try another browser.")
451455
} else {
452456
"linux64"
453457
}

rust/src/edge.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ impl SeleniumManager for EdgeManager {
288288
} else {
289289
"mac64"
290290
}
291+
} else if LINUX.is(os) && ARM64.is(arch) {
292+
panic!("Linux arm64 is not supported yet by Microsoft Edge. Please try another browser.")
291293
} else {
292294
"linux64"
293295
};
@@ -354,6 +356,8 @@ impl SeleniumManager for EdgeManager {
354356
} else {
355357
"mac64"
356358
}
359+
} else if LINUX.is(os) && ARM64.is(arch) {
360+
panic!("Linux arm64 is not supported yet by Microsoft Edge. Please try another browser.")
357361
} else {
358362
"linux64"
359363
}

rust/tests/browser_download_tests.rs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use crate::common::{assert_browser, assert_driver, get_selenium_manager};
1919

2020
use rstest::rstest;
21+
use std::env::consts::ARCH;
2122
use std::env::consts::OS;
2223

2324
mod common;
@@ -27,23 +28,27 @@ mod common;
2728
#[case("firefox")]
2829
#[case("edge")]
2930
fn browser_latest_download_test(#[case] browser: String) {
30-
if !browser.eq("edge") || !OS.eq("windows") {
31-
let mut cmd = get_selenium_manager();
32-
cmd.args([
33-
"--browser",
34-
&browser,
35-
"--force-browser-download",
36-
"--output",
37-
"json",
38-
"--debug",
39-
])
40-
.assert()
41-
.success()
42-
.code(0);
43-
44-
assert_driver(&mut cmd);
45-
assert_browser(&mut cmd);
31+
if browser.eq("edge") && OS.eq("windows") {
32+
return
33+
} else if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
34+
return
4635
}
36+
37+
let mut cmd = get_selenium_manager();
38+
cmd.args([
39+
"--browser",
40+
&browser,
41+
"--force-browser-download",
42+
"--output",
43+
"json",
44+
"--debug",
45+
])
46+
.assert()
47+
.success()
48+
.code(0);
49+
50+
assert_driver(&mut cmd);
51+
assert_browser(&mut cmd);
4752
}
4853

4954
#[rstest]
@@ -59,6 +64,8 @@ fn browser_latest_download_test(#[case] browser: String) {
5964
fn browser_version_download_test(#[case] browser: String, #[case] browser_version: String) {
6065
if OS.eq("windows") && browser.eq("edge") {
6166
println!("Skipping Edge download test on Windows since the installation requires admin privileges");
67+
} else if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
68+
println!("Skipping non-Firefox download test on Linux arm64 since no other browsers are supported yet");
6269
} else {
6370
let mut cmd = get_selenium_manager();
6471
cmd.args([

rust/tests/browser_tests.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::common::{assert_output, get_selenium_manager, get_stdout};
1919

2020
use exitcode::DATAERR;
2121
use rstest::rstest;
22+
use std::env::consts::ARCH;
2223
use std::env::consts::OS;
2324
use std::path::Path;
2425

@@ -40,6 +41,10 @@ fn browser_version_test(
4041
#[case] browser_version: String,
4142
#[case] driver_version: String,
4243
) {
44+
if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
45+
return
46+
}
47+
4348
let mut cmd = get_selenium_manager();
4449
cmd.args([
4550
"--browser",
@@ -78,6 +83,10 @@ fn wrong_parameters_test(
7883
#[case] driver_version: String,
7984
#[case] error_code: i32,
8085
) {
86+
if OS.eq("linux") && ARCH.eq("aarch64") && !browser.eq("firefox") {
87+
return
88+
}
89+
8190
let mut cmd = get_selenium_manager();
8291
let result = cmd
8392
.args([

rust/tests/cache_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::path::Path;
2323

2424
mod common;
2525

26+
#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]
2627
#[rstest]
2728
#[case("../tmp")]
2829
#[case("../áèîö")]

rust/tests/common.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use selenium_manager::logger::JsonOutput;
2323
use selenium_manager::shell;
2424
use selenium_manager::shell::run_shell_command_by_os;
2525
use std::borrow::BorrowMut;
26+
use std::env::consts::ARCH;
2627
use std::env::consts::OS;
2728
use std::path::{Path, PathBuf};
2829

@@ -119,3 +120,8 @@ pub fn assert_output(
119120
.contains(&error_code.to_string()));
120121
}
121122
}
123+
124+
#[allow(dead_code)]
125+
pub fn is_linux_arm64() -> bool {
126+
OS == "linux" && ARCH == "aarch64"
127+
}

rust/tests/config_tests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use crate::common::{assert_browser, assert_driver, get_selenium_manager, get_std
1919

2020
use rstest::rstest;
2121

22+
use std::env::consts::ARCH;
23+
use std::env::consts::OS;
2224
use std::fs::File;
2325
use std::io::{BufWriter, Write};
2426
use tempfile::Builder;
@@ -30,6 +32,9 @@ mod common;
3032
#[case("firefox")]
3133
#[case("edge")]
3234
fn config_test(#[case] browser_name: String) {
35+
if OS.eq("linux") && ARCH.eq("aarch64") && !browser_name.eq("firefox") {
36+
return
37+
}
3338
let tmp_dir = Builder::new().prefix("sm-config-test").tempdir().unwrap();
3439
let config_path = tmp_dir.path().join("se-config.toml");
3540
let config_file = File::create(config_path.as_path()).unwrap();

rust/tests/exec_driver_tests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use crate::common::{assert_browser, assert_driver, exec_driver, get_selenium_manager};
1919

2020
use rstest::rstest;
21+
use std::env::consts::ARCH;
2122
use std::env::consts::OS;
2223

2324
mod common;
@@ -28,6 +29,10 @@ mod common;
2829
#[case("firefox", "geckodriver")]
2930
#[case("iexplorer", "IEDriverServer")]
3031
fn exec_driver_test(#[case] browser_name: String, #[case] driver_name: String) {
32+
if OS.eq("linux") && ARCH.eq("aarch64") && !browser_name.eq("firefox") {
33+
return
34+
}
35+
3136
let mut cmd = get_selenium_manager();
3237
cmd.args(["--browser", &browser_name, "--output", "json"])
3338
.assert()

rust/tests/mirror_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use crate::common::{assert_driver, get_selenium_manager};
18+
use crate::common::{assert_driver, is_linux_arm64, get_selenium_manager};
1919

2020
mod common;
2121

@@ -24,7 +24,7 @@ fn mirror_test() {
2424
let mut cmd = get_selenium_manager();
2525
cmd.args([
2626
"--browser",
27-
"chrome",
27+
if is_linux_arm64() { "firefox" } else { "chrome" },
2828
"--driver-mirror-url",
2929
"https://registry.npmmirror.com/-/binary/chromedriver/",
3030
"--browser-version",

rust/tests/offline_tests.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use crate::common::{get_selenium_manager, get_stdout};
18+
use crate::common::{get_selenium_manager, get_stdout, is_linux_arm64};
1919

2020
mod common;
2121

2222
#[test]
2323
fn offline_test() {
2424
let mut cmd = get_selenium_manager();
25-
cmd.args(["--debug", "--browser", "chrome", "--offline"])
26-
.assert()
27-
.success()
28-
.code(0);
25+
cmd.args([
26+
"--debug",
27+
"--browser",
28+
if is_linux_arm64() { "firefox" } else { "chrome" },
29+
"--offline"
30+
])
31+
.assert()
32+
.success()
33+
.code(0);
2934

3035
let stdout = get_stdout(&mut cmd);
3136

0 commit comments

Comments
 (0)