mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-27 08:15:06 -06:00
nightly-tests: give the launcher fixture the platform's absolute profile root
`launcher_argv` started a nightly with `/nightly-data/profiles/gridcraft`. Rust needs a prefix and a root for an absolute path on Windows, so that spelling is relative there, `launch_profile::parse` refuses it, and every test that builds argv with it fails on windows-latest - which runs this suite. `launcher_root()` now returns the platform's spelling (`C:\NightlyData\profiles\gridcraft` on Windows, `/nightly-data/profiles/gridcraft` elsewhere), and a new case refuses the other platform's spelling so the fixture cannot drift back to a POSIX-only literal.
This commit is contained in:
@@ -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<String> {
|
||||
let mut argv: Vec<std::ffi::OsString> = ["--launch-profile", "nightly-v1", "--profile-root", "/nightly-data/profiles/gridcraft", "--"]
|
||||
let mut argv: Vec<std::ffi::OsString> = ["--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<std::ffi::OsString> = ["--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);
|
||||
|
||||
Reference in New Issue
Block a user