Skip to content

Commit 3277aaa

Browse files
committed
[libcxx] [test] Skip timezone formatting tests on Windows
While these tests do pass in the CI environment, they fail elsewhere. On GitHub Action runners, they produce '+0000' instead of '-0000' for the UTC offset, and on local machines, it outputs the UTC offset of the local timezone. Differential Revision: https://reviews.llvm.org/D155182
1 parent 61d2a9b commit 3277aaa

File tree

2 files changed

+8
-36
lines changed

2 files changed

+8
-36
lines changed

libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,9 @@ static void test_valid_values_time_zone() {
861861
// The Apple CI gives %z='-0700' %Ez='-0700' %Oz='-0700' %Z='UTC'
862862
// -0700 looks like the local time where the CI happens to recide, therefore
863863
// omit this test on Apple.
864-
#if !defined(__APPLE__)
864+
// The Windows CI gives %z='-0000', but on local machines set to a different
865+
// timezone, it gives e.g. %z='+0200'.
866+
#if !defined(__APPLE__) && !defined(_WIN32)
865867
using namespace std::literals::chrono_literals;
866868

867869
constexpr std::basic_string_view<CharT> fmt = SV("{:%%z='%z'%t%%Ez='%Ez'%t%%Oz='%Oz'%t%%Z='%Z'%n}");
@@ -886,22 +888,6 @@ static void test_valid_values_time_zone() {
886888
SV("%z='UTC'\t%Ez='UTC'\t%Oz='UTC'\t%Z='UTC'\n"),
887889
lfmt,
888890
file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
889-
# elif defined(_WIN32) // defined(_AIX)
890-
// Non localized output using C-locale
891-
check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"),
892-
fmt,
893-
file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
894-
895-
// Use the global locale (fr_FR)
896-
check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"),
897-
lfmt,
898-
file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
899-
900-
// Use supplied locale (ja_JP). This locale has a different alternate.a
901-
check(loc,
902-
SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"),
903-
lfmt,
904-
file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
905891
# else // defined(_AIX)
906892
// Non localized output using C-locale
907893
check(SV("%z='+0000'\t%Ez='+0000'\t%Oz='+0000'\t%Z='UTC'\n"),
@@ -920,7 +906,7 @@ static void test_valid_values_time_zone() {
920906
file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
921907
# endif // defined(_AIX)
922908
std::locale::global(std::locale::classic());
923-
#endif // !defined(__APPLE__)
909+
#endif // !defined(__APPLE__) && !defined(_WIN32)
924910
}
925911

926912
template <class CharT>

libcxx/test/std/time/time.syn/formatter.sys_time.pass.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,9 @@ static void test_valid_values_time_zone() {
859859
// The Apple CI gives %z='-0700' %Ez='-0700' %Oz='-0700' %Z='UTC'
860860
// -0700 looks like the local time where the CI happens to recide, therefore
861861
// omit this test on Apple.
862-
#if !defined(__APPLE__)
862+
// The Windows CI gives %z='-0000', but on local machines set to a different
863+
// timezone, it gives e.g. %z='+0200'.
864+
#if !defined(__APPLE__) && !defined(_WIN32)
863865
using namespace std::literals::chrono_literals;
864866

865867
constexpr std::basic_string_view<CharT> fmt = SV("{:%%z='%z'%t%%Ez='%Ez'%t%%Oz='%Oz'%t%%Z='%Z'%n}");
@@ -884,22 +886,6 @@ static void test_valid_values_time_zone() {
884886
SV("%z='UTC'\t%Ez='UTC'\t%Oz='UTC'\t%Z='UTC'\n"),
885887
lfmt,
886888
std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
887-
# elif defined(_WIN32) // defined(_AIX)
888-
// Non localized output using C-locale
889-
check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"),
890-
fmt,
891-
std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
892-
893-
// Use the global locale (fr_FR)
894-
check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"),
895-
lfmt,
896-
std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
897-
898-
// Use supplied locale (ja_JP). This locale has a different alternate.a
899-
check(loc,
900-
SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"),
901-
lfmt,
902-
std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
903889
# else // defined(_AIX)
904890
// Non localized output using C-locale
905891
check(SV("%z='+0000'\t%Ez='+0000'\t%Oz='+0000'\t%Z='UTC'\n"),
@@ -918,7 +904,7 @@ static void test_valid_values_time_zone() {
918904
std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
919905
# endif // defined(_AIX)
920906
std::locale::global(std::locale::classic());
921-
#endif // !defined(__APPLE__)
907+
#endif // !defined(__APPLE__) && !defined(_WIN32)
922908
}
923909

924910
template <class CharT>

0 commit comments

Comments
 (0)