From 183d8420477d3d9f90e7d6afd03ff4ba43a5feec Mon Sep 17 00:00:00 2001 From: Tina Liu Date: Thu, 10 Jul 2025 16:54:46 -0700 Subject: [PATCH 1/2] test individualFields() 155519959 --- .../Formatting/DateFormatStyleTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift index 83dabb19f..1a652fd14 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift @@ -635,7 +635,7 @@ private struct DateAttributedFormatStyleTests { } @Test func individualFields() throws { - let baseStyle = Date.FormatStyle(locale: enUSLocale, timeZone: gmtTimeZone) + let baseStyle = Date.FormatStyle(locale: enUSLocale, calendar: Calendar(identifier: .gregorian), timeZone: gmtTimeZone) // dateFormatter.date(from: "2021-04-12 15:04:32")! let date = Date(timeIntervalSinceReferenceDate: 639932672.0) let expectations: [Date.FormatStyle : [Segment]] = [ From d42a4b2bb7e715d2e0cd391c244b0cd4cb715a1d Mon Sep 17 00:00:00 2001 From: Tina Liu Date: Thu, 10 Jul 2025 17:57:08 -0700 Subject: [PATCH 2/2] 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 --- .../Formatting/DateFormatStyleTests.swift | 8 ++++++-- .../Formatting/NumberFormatStyleTests.swift | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift index 1a652fd14..12d0d055e 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift @@ -291,7 +291,7 @@ private struct DateFormatStyleTests { #expect(date.formatted(style.locale(Locale.localeAsIfCurrent(name: esES, overrides: .init(force24Hour: true)))) == "16:00:00") } -#if !os(watchOS) // 99504292 +#if !os(watchOS) && FOUNDATION_FRAMEWORK // 99504292 && 155484008 @Test func nsICUDateFormatterCache() async throws { await usingCurrentInternationalizationPreferences { // This test can only be run with the system set to the en_US language @@ -405,7 +405,8 @@ private struct DateFormatStyleTests { var locale: Locale var format: Date.FormatStyle func verifyWithFormat(_ date: Date, expected: String, sourceLocation: SourceLocation = #_sourceLocation) { - let fmt = format.locale(locale) + var fmt = format.locale(locale) + fmt.calendar = Calendar(identifier: .gregorian) let formatted = fmt.format(date) #expect(formatted == expected, sourceLocation: sourceLocation) } @@ -1408,6 +1409,7 @@ private struct TestDateStyleDiscreteConformance { let now = date("2023-05-15 08:47:20Z") +#if FOUNDATION_FRAMEWORK // 155526268 assertEvaluation( of: .init(date: .complete, time: .complete).secondFraction(.fractional(2)), in: (now - 0.1)...(now + 0.1), @@ -1435,6 +1437,7 @@ private struct TestDateStyleDiscreteConformance { "Monday, May 15, 2023 at 8:47:20.10 AM GMT", ]) + assertEvaluation( of: .init(date: .complete, time: .complete), in: (now - 3)...(now + 3), @@ -1447,6 +1450,7 @@ private struct TestDateStyleDiscreteConformance { "Monday, May 15, 2023 at 8:47:22 AM GMT", "Monday, May 15, 2023 at 8:47:23 AM GMT", ]) +#endif assertEvaluation( of: .init().hour(.twoDigits(amPM: .abbreviated)).minute(), diff --git a/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift index 67d840c6b..16e9fa453 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift @@ -1820,7 +1820,7 @@ private struct FormatStylePatternMatchingTests { typealias TestCase = (string: String, style: IntegerFormatStyle, value: Int?) @Test func integerFormatStyle_Consumer() { - let style: IntegerFormatStyle = .init() + let style: IntegerFormatStyle = .init(locale: Locale(identifier: "en_US")) let string = "42,000,000" _verifyMatching(string, formatStyle: style, expectedUpperBound: string.endIndex, expectedValue: 42000000) @@ -1860,7 +1860,7 @@ private struct FormatStylePatternMatchingTests { } @Test func percentFormatStyle_Consumer() { - let style = IntegerFormatStyle.Percent() + let style = IntegerFormatStyle.Percent(locale: Locale(identifier: "en_US")) let string = "42%" _verifyMatching(string, formatStyle: style, expectedUpperBound: string.endIndex, expectedValue: 42)