Skip to content

Commit aef3918

Browse files
committed
[rust] allow tests to find selenium manager in both linux and windows
handling the exe extension in windows can be complicated
1 parent dd789f2 commit aef3918

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: rust/tests/common.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,24 @@ use selenium_manager::shell;
2424
use selenium_manager::shell::run_shell_command_by_os;
2525
use std::borrow::BorrowMut;
2626
use std::env::consts::OS;
27-
use std::path::Path;
27+
use std::path::{Path, PathBuf};
2828

2929
#[allow(dead_code)]
3030
pub fn get_selenium_manager() -> Command {
31-
let path = env!("CARGO_BIN_EXE_selenium-manager");
31+
let mut path = PathBuf::from(env!("CARGO_BIN_EXE_selenium-manager"));
3232

33-
if Path::new(path).exists() {
33+
if path.exists() {
3434
return Command::new(path);
3535
}
3636

37-
panic!("Binary not found {}", path)
37+
if cfg!(windows) {
38+
let exe_path = path.with_extension("exe");
39+
if exe_path.exists() {
40+
return Command::new(exe_path);
41+
}
42+
}
43+
44+
panic!("Binary not found {}", path_to_string(&path));
3845
}
3946

4047
#[allow(dead_code)]

0 commit comments

Comments
 (0)