Skip to content

Commit

Permalink
[rust] Simplify syntax for raw strings
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Nov 3, 2023
1 parent 1182189 commit c84ec6f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions rust/src/chrome.rs
Expand Up @@ -220,19 +220,19 @@ impl SeleniumManager for ChromeManager {
HashMap::from([
(
BrowserPath::new(WINDOWS, STABLE),
r#"Google\Chrome\Application\chrome.exe"#,
r"Google\Chrome\Application\chrome.exe",
),
(
BrowserPath::new(WINDOWS, BETA),
r#"Google\Chrome Beta\Application\chrome.exe"#,
r"Google\Chrome Beta\Application\chrome.exe",
),
(
BrowserPath::new(WINDOWS, DEV),
r#"Google\Chrome Dev\Application\chrome.exe"#,
r"Google\Chrome Dev\Application\chrome.exe",
),
(
BrowserPath::new(WINDOWS, NIGHTLY),
r#"Google\Chrome SxS\Application\chrome.exe"#,
r"Google\Chrome SxS\Application\chrome.exe",
),
(
BrowserPath::new(MACOS, STABLE),
Expand Down Expand Up @@ -261,7 +261,7 @@ impl SeleniumManager for ChromeManager {

fn discover_browser_version(&mut self) -> Result<Option<String>, Error> {
self.general_discover_browser_version(
r#"HKCU\Software\Google\Chrome\BLBeacon"#,
r"HKCU\Software\Google\Chrome\BLBeacon",
REG_VERSION_ARG,
DASH_DASH_VERSION,
)
Expand Down
16 changes: 8 additions & 8 deletions rust/src/edge.rs
Expand Up @@ -107,25 +107,25 @@ impl SeleniumManager for EdgeManager {
if self.is_webview2() {
HashMap::from([(
BrowserPath::new(WINDOWS, STABLE),
r#"Microsoft\EdgeWebView\Application"#,
r"Microsoft\EdgeWebView\Application",
)])
} else {
HashMap::from([
(
BrowserPath::new(WINDOWS, STABLE),
r#"Microsoft\Edge\Application\msedge.exe"#,
r"Microsoft\Edge\Application\msedge.exe",
),
(
BrowserPath::new(WINDOWS, BETA),
r#"Microsoft\Edge Beta\Application\msedge.exe"#,
r"Microsoft\Edge Beta\Application\msedge.exe",
),
(
BrowserPath::new(WINDOWS, DEV),
r#"Microsoft\Edge Dev\Application\msedge.exe"#,
r"Microsoft\Edge Dev\Application\msedge.exe",
),
(
BrowserPath::new(WINDOWS, NIGHTLY),
r#"Microsoft\Edge SxS\Application\msedge.exe"#,
r"Microsoft\Edge SxS\Application\msedge.exe",
),
(
BrowserPath::new(MACOS, STABLE),
Expand Down Expand Up @@ -158,20 +158,20 @@ impl SeleniumManager for EdgeManager {
let arch = self.get_arch();
if X32.is(arch) {
(
r#"HKLM\SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"#,
r"HKLM\SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}",
REG_PV_ARG,
"",
)
} else {
(
r#"HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"#,
r"HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}",
REG_PV_ARG,
"",
)
}
} else {
(
r#"HKCU\Software\Microsoft\Edge\BLBeacon"#,
r"HKCU\Software\Microsoft\Edge\BLBeacon",
REG_VERSION_ARG,
DASH_DASH_VERSION,
)
Expand Down
14 changes: 7 additions & 7 deletions rust/src/firefox.rs
Expand Up @@ -56,7 +56,7 @@ const FIREFOX_HISTORY_DEV_ENDPOINT: &str = "firefox_history_development_releases
const FIREFOX_NIGHTLY_URL: &str =
"https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os={}&lang={}";
const FIREFOX_VOLUME: &str = "Firefox";
const FIREFOX_NIGHTLY_VOLUME: &str = r#"Firefox\ Nightly"#;
const FIREFOX_NIGHTLY_VOLUME: &str = r"Firefox\ Nightly";
const MIN_DOWNLOADABLE_FIREFOX_VERSION_WIN: i32 = 13;
const MIN_DOWNLOADABLE_FIREFOX_VERSION_MAC: i32 = 4;
const MIN_DOWNLOADABLE_FIREFOX_VERSION_LINUX: i32 = 4;
Expand Down Expand Up @@ -132,24 +132,24 @@ impl SeleniumManager for FirefoxManager {
HashMap::from([
(
BrowserPath::new(WINDOWS, STABLE),
r#"Mozilla Firefox\firefox.exe"#,
r"Mozilla Firefox\firefox.exe",
),
(
BrowserPath::new(WINDOWS, BETA),
// "",
r#"Mozilla Firefox\firefox.exe"#,
r"Mozilla Firefox\firefox.exe",
),
(
BrowserPath::new(WINDOWS, DEV),
r#"Firefox Developer Edition\firefox.exe"#,
r"Firefox Developer Edition\firefox.exe",
),
(
BrowserPath::new(WINDOWS, NIGHTLY),
r#"Firefox Nightly\firefox.exe"#,
r"Firefox Nightly\firefox.exe",
),
(
BrowserPath::new(WINDOWS, ESR),
r#"Mozilla Firefox\firefox.exe"#,
r"Mozilla Firefox\firefox.exe",
),
(
BrowserPath::new(MACOS, STABLE),
Expand Down Expand Up @@ -181,7 +181,7 @@ impl SeleniumManager for FirefoxManager {

fn discover_browser_version(&mut self) -> Result<Option<String>, Error> {
self.general_discover_browser_version(
r#"HKCU\Software\Mozilla\Mozilla Firefox"#,
r"HKCU\Software\Mozilla\Mozilla Firefox",
REG_CURRENT_VERSION_ARG,
DASH_VERSION,
)
Expand Down
4 changes: 2 additions & 2 deletions rust/src/iexplorer.rs
Expand Up @@ -93,13 +93,13 @@ impl SeleniumManager for IExplorerManager {
fn get_browser_path_map(&self) -> HashMap<BrowserPath, &str> {
HashMap::from([(
BrowserPath::new(WINDOWS, STABLE),
r#"Internet Explorer\iexplore.exe"#,
r"Internet Explorer\iexplore.exe",
)])
}

fn discover_browser_version(&mut self) -> Result<Option<String>, Error> {
self.general_discover_browser_version(
r#"HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer"#,
r"HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer",
REG_VERSION_ARG,
"",
)
Expand Down
2 changes: 1 addition & 1 deletion rust/src/lib.rs
Expand Up @@ -110,7 +110,7 @@ pub const UNAVAILABLE_DOWNLOAD_WITH_MIN_VERSION_ERR_MSG: &str =
pub const NOT_ADMIN_FOR_EDGE_INSTALLER_ERR_MSG: &str =
"{} can only be installed in Windows with administrator permissions";
pub const ONLINE_DISCOVERY_ERROR_MESSAGE: &str = "Unable to discover {}{} in online repository";
pub const UNC_PREFIX: &str = r#"\\?\"#;
pub const UNC_PREFIX: &str = r"\\?\";

pub trait SeleniumManager {
// ----------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion rust/src/safaritp.rs
Expand Up @@ -29,7 +29,7 @@ use std::string::ToString;
pub const SAFARITP_NAMES: &[&str] = &[
"safaritp",
"safari technology preview",
r#"safari\ technology\ preview"#,
r"safari\ technology\ preview",
"safaritechnologypreview",
];
pub const SAFARITPDRIVER_NAME: &str = "safaridriver";
Expand Down
6 changes: 3 additions & 3 deletions rust/tests/browser_tests.rs
Expand Up @@ -114,18 +114,18 @@ fn browser_beta_test(#[case] browser: String, #[case] driver_name: String) {
#[case(
"windows",
"chrome",
r#"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"#
r"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
)]
#[case(
"windows",
"chrome",
r#"C:\Program Files\Google\Chrome\Application\chrome.exe"#
r"C:\Program Files\Google\Chrome\Application\chrome.exe"
)]
#[case("linux", "chrome", "/usr/bin/google-chrome")]
#[case(
"macos",
"chrome",
r#"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"#
r"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
)]
#[case(
"macos",
Expand Down
2 changes: 1 addition & 1 deletion rust/tests/cache_tests.rs
Expand Up @@ -40,7 +40,7 @@ fn cache_path_test() {

let driver_path = get_driver_path(&mut cmd);
println!("*** Custom cache path: {}", driver_path);
assert!(!driver_path.contains(r#"cache\selenium"#));
assert!(!driver_path.contains(r"cache\selenium"));

let tmp_cache_path = Path::new(tmp_cache_folder_name);
fs::remove_dir_all(tmp_cache_path).unwrap();
Expand Down

0 comments on commit c84ec6f

Please sign in to comment.