From 4c8e40c19166258459aa7a53e9d91008d9c19bf1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 1 Dec 2026 04:18:47 -0800 Subject: [PATCH] Tests: ignore a trailing comment after the nightly id assignment The packaging check's `assigned` helper now drops a `#` comment that follows the value, quoted or bare, so `IDENTIFIER = "x" # bundle ID` still reads as `x`. --- crates/ui-egui/src/os_window.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/os_window.rs b/crates/ui-egui/src/os_window.rs index 72575b951f..49f7190275 100644 --- a/crates/ui-egui/src/os_window.rs +++ b/crates/ui-egui/src/os_window.rs @@ -130,14 +130,20 @@ mod tests { } /// The value of the last uncommented top-level `name = value` or `name=value` line, with one pair of - /// single or double quotes removed. + /// single or double quotes removed and a trailing `#` comment after the value ignored. fn assigned<'a>(source: &'a str, name: &str) -> Option<&'a str> { source .lines() .filter_map(|line| { let rest = line.strip_prefix(name)?.trim_start().strip_prefix('=')?.trim(); - let unquoted = ['\'', '"'].iter().find_map(|q| rest.strip_prefix(*q)?.strip_suffix(*q)); - Some(unquoted.unwrap_or(rest)) + let quoted = ['\'', '"'].iter().find_map(|q| { + let inner = rest.strip_prefix(*q)?; + let end = inner.find(*q)?; + let after = inner[end + 1..].trim(); + (after.is_empty() || after.starts_with('#')).then(|| &inner[..end]) + }); + let bare = rest.split_once(" #").map_or(rest, |(value, _)| value.trim_end()); + Some(quoted.unwrap_or(bare)) }) .next_back() } @@ -147,6 +153,9 @@ mod tests { assert_eq!(assigned("# ID='old'\nID=\"new\"\n", "ID"), Some("new")); assert_eq!(assigned("ID = 'a'\n", "ID"), Some("a")); assert_eq!(assigned("IDX='a'\n", "ID"), None); + assert_eq!(assigned("ID = 'a' # bundle ID\n", "ID"), Some("a")); + assert_eq!(assigned("ID=\"a\" # bundle ID\n", "ID"), Some("a")); + assert_eq!(assigned("ID=a # bundle ID\n", "ID"), Some("a")); } #[test]