Skip to content

Commit 5704355

Browse files
committed
test(date): Relax locale format assertions to support variable CI environments
1 parent e6a9637 commit 5704355

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/uu/date/src/locale.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ mod tests {
131131
target_os = "dragonfly"
132132
))]
133133
{
134-
assert!(format.contains("%a")); // abbreviated weekday
135-
assert!(format.contains("%b")); // abbreviated month
136-
assert!(format.contains("%Y") || format.contains("%y")); // year (4-digit or 2-digit)
137-
assert!(format.contains("%Z")); // timezone
134+
// We only strictly check for timezone because ensure_timezone_in_format guarantees it
135+
assert!(format.contains("%Z") || format.contains("%z")); // timezone
136+
137+
// Other components depend on the system locale and might vary (e.g. %F, %c, etc.)
138+
// so we don't strictly assert %a or %b here.
138139
}
139140
}
140141

@@ -156,16 +157,24 @@ mod tests {
156157
|| format.contains("%b")
157158
|| format.contains("%B")
158159
|| format.contains("%d")
159-
|| format.contains("%e");
160+
|| format.contains("%e")
161+
|| format.contains("%F") // YYYY-MM-DD
162+
|| format.contains("%D") // MM/DD/YY
163+
|| format.contains("%x") // Locale's date representation
164+
|| format.contains("%c") // Locale's date and time
165+
|| format.contains("%+"); // date(1) extended format
160166
assert!(has_date_component, "Format should contain date components");
167+
161168
let has_time_component = format.contains("%H")
162169
|| format.contains("%I")
163170
|| format.contains("%k")
164171
|| format.contains("%l")
165172
|| format.contains("%r")
166173
|| format.contains("%R")
167174
|| format.contains("%T")
168-
|| format.contains("%X");
175+
|| format.contains("%X")
176+
|| format.contains("%c") // Locale's date and time
177+
|| format.contains("%+"); // date(1) extended format
169178
assert!(has_time_component, "Format should contain time components");
170179
}
171180
}

0 commit comments

Comments
 (0)