diff --git a/apps/gridcraft/src/main.rs b/apps/gridcraft/src/main.rs index 3b78114a8..d0c71fd2e 100644 --- a/apps/gridcraft/src/main.rs +++ b/apps/gridcraft/src/main.rs @@ -659,9 +659,16 @@ mod launch_separator_tests { use super::*; use crate::build_flavor::BuildFlavor; + /// The profile root a Launcher run is started with: absolute for the platform the test runs on. + /// `launch_profile::parse` refuses a root that is relative there, and a POSIX path has no drive + /// or UNC prefix, so it is not absolute on Windows - where CI runs these tests too. + fn launcher_root() -> &'static str { + if cfg!(windows) { r"C:\NightlyData\profiles\gridcraft" } else { "/nightly-data/profiles/gridcraft" } + } + /// The argv the Launcher starts a nightly with, extended by `tail`, as the start then reads it. fn launcher_argv(tail: &[&str]) -> Vec { - let mut argv: Vec = ["--launch-profile", "nightly-v1", "--profile-root", "/nightly-data/profiles/gridcraft", "--"] + let mut argv: Vec = ["--launch-profile", "nightly-v1", "--profile-root", launcher_root(), "--"] .iter() .map(std::ffi::OsString::from) .collect(); @@ -669,6 +676,16 @@ mod launch_separator_tests { launch_profile::parse(argv).unwrap().args.iter().map(|a| a.to_string_lossy().into_owned()).collect() } + #[test] + fn the_other_platforms_root_spelling_is_refused_as_relative() { + let foreign = if cfg!(windows) { "/nightly-data/profiles/gridcraft" } else { r"C:\NightlyData\profiles\gridcraft" }; + let argv: Vec = ["--launch-profile", "nightly-v1", "--profile-root", foreign, "--"] + .iter() + .map(std::ffi::OsString::from) + .collect(); + assert!(launch_profile::parse(argv).is_err(), "a root that is not absolute on this platform must be refused"); + } + #[test] fn the_launchers_separator_is_never_a_file() { let parsed = desktop_args(&launcher_argv(&[]), None, None);