Skip to content

Commit d42a4b2

Browse files
committed
Disable various failing tests
I believe these tests are failing because some other tests are mutating the global cached current locale or calendar. We've identified most tests whose test expectations depend on the current locale. We've addressed them by either specifying a fixed locale on the tests, or guard them inside `usingCurrentInternationalizationPreferences`. But even if a test doesn't assert the result based on the value of the current locale, the test might still cause the cache to be populated concurrently at the time of accessing autoupdating and current locale, and subsequently break tests that expect a given value of the current locale. Disable the tests for now while investigating a proper way to update the tests. These tests pass when building as part of the Darwin SDK, so leave them enabled there. 155476600
1 parent 183d842 commit d42a4b2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private struct DateFormatStyleTests {
291291
#expect(date.formatted(style.locale(Locale.localeAsIfCurrent(name: esES, overrides: .init(force24Hour: true)))) == "16:00:00")
292292
}
293293

294-
#if !os(watchOS) // 99504292
294+
#if !os(watchOS) && FOUNDATION_FRAMEWORK // 99504292 && 155484008
295295
@Test func nsICUDateFormatterCache() async throws {
296296
await usingCurrentInternationalizationPreferences {
297297
// This test can only be run with the system set to the en_US language
@@ -405,7 +405,8 @@ private struct DateFormatStyleTests {
405405
var locale: Locale
406406
var format: Date.FormatStyle
407407
func verifyWithFormat(_ date: Date, expected: String, sourceLocation: SourceLocation = #_sourceLocation) {
408-
let fmt = format.locale(locale)
408+
var fmt = format.locale(locale)
409+
fmt.calendar = Calendar(identifier: .gregorian)
409410
let formatted = fmt.format(date)
410411
#expect(formatted == expected, sourceLocation: sourceLocation)
411412
}
@@ -1408,6 +1409,7 @@ private struct TestDateStyleDiscreteConformance {
14081409

14091410
let now = date("2023-05-15 08:47:20Z")
14101411

1412+
#if FOUNDATION_FRAMEWORK // 155526268
14111413
assertEvaluation(
14121414
of: .init(date: .complete, time: .complete).secondFraction(.fractional(2)),
14131415
in: (now - 0.1)...(now + 0.1),
@@ -1435,6 +1437,7 @@ private struct TestDateStyleDiscreteConformance {
14351437
"Monday, May 15, 2023 at 8:47:20.10 AM GMT",
14361438
])
14371439

1440+
14381441
assertEvaluation(
14391442
of: .init(date: .complete, time: .complete),
14401443
in: (now - 3)...(now + 3),
@@ -1447,6 +1450,7 @@ private struct TestDateStyleDiscreteConformance {
14471450
"Monday, May 15, 2023 at 8:47:22 AM GMT",
14481451
"Monday, May 15, 2023 at 8:47:23 AM GMT",
14491452
])
1453+
#endif
14501454

14511455
assertEvaluation(
14521456
of: .init().hour(.twoDigits(amPM: .abbreviated)).minute(),

Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ private struct FormatStylePatternMatchingTests {
18201820
typealias TestCase = (string: String, style: IntegerFormatStyle<Int>, value: Int?)
18211821

18221822
@Test func integerFormatStyle_Consumer() {
1823-
let style: IntegerFormatStyle<Int> = .init()
1823+
let style: IntegerFormatStyle<Int> = .init(locale: Locale(identifier: "en_US"))
18241824
let string = "42,000,000"
18251825

18261826
_verifyMatching(string, formatStyle: style, expectedUpperBound: string.endIndex, expectedValue: 42000000)
@@ -1860,7 +1860,7 @@ private struct FormatStylePatternMatchingTests {
18601860
}
18611861

18621862
@Test func percentFormatStyle_Consumer() {
1863-
let style = IntegerFormatStyle<Int>.Percent()
1863+
let style = IntegerFormatStyle<Int>.Percent(locale: Locale(identifier: "en_US"))
18641864
let string = "42%"
18651865

18661866
_verifyMatching(string, formatStyle: style, expectedUpperBound: string.endIndex, expectedValue: 42)

0 commit comments

Comments
 (0)