[libcxx-commits] [PATCH] D120546: [libcxx] [test] Fix dsl.sh.py to work on Windows.

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 25 01:25:46 PST 2022


mstorsjo created this revision.
mstorsjo added reviewers: Quuxplusone, ldionne, Mordante.
Herald added a subscriber: arichardson.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Convert CRLF to LF in the output of tested commands.

Windows UCRT has got a bug in older versions (present in CI), where
it successfully does set a locale named
`for_sure_this_is_not_an_existing_locale`. By adjusting the tested
locale name to `forsurethisisnotanexistinglocale`, that test works
as expected, failing to set the locale.

The bug is reported upstream at
https://developercommunity.visualstudio.com/t/setlocale-succeeds-for-bogus-locale-names-in-older/1652241,
but as it already is working correctly in newer versions, no action
was prompted there.

We could of course add a bug detection in features.py like other
existing `win32-broken-*` features, but that would seem kinda
pointless as it would be doing exactly what this test does.
Instead just adjust the tested dummy locale name, and leave a note
so that it can be restored when CI uses a newer version of Windows/UCRT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120546

Files:
  libcxx/test/libcxx/selftest/dsl/dsl.sh.py
  libcxx/utils/libcxx/test/dsl.py


Index: libcxx/utils/libcxx/test/dsl.py
===================================================================
--- libcxx/utils/libcxx/test/dsl.py
+++ libcxx/utils/libcxx/test/dsl.py
@@ -173,6 +173,8 @@
 
     actualOut = re.search("# command output:\n(.+)\n$", out, flags=re.DOTALL)
     actualOut = actualOut.group(1) if actualOut else ""
+    if platform.system() == 'Windows':
+      actualOut = actualOut.replace('\r\n', '\n')
     return actualOut
 
 @_memoizeExpensiveOperation(lambda c, p, args=None: (c.substitutions, c.environment, p, args))
Index: libcxx/test/libcxx/selftest/dsl/dsl.sh.py
===================================================================
--- libcxx/test/libcxx/selftest/dsl/dsl.sh.py
+++ libcxx/test/libcxx/selftest/dsl/dsl.sh.py
@@ -6,8 +6,6 @@
 #
 #===----------------------------------------------------------------------===##
 
-# XFAIL: LIBCXX-WINDOWS-FIXME
-
 # Note: We prepend arguments with 'x' to avoid thinking there are too few
 #       arguments in case an argument is an empty string.
 # RUN: %{python} %s x%S x%T x%{substitutions}
@@ -251,7 +249,11 @@
             self.fail("checking for hasLocale should not explode")
 
     def test_nonexistent_locale(self):
-        self.assertFalse(dsl.hasAnyLocale(self.config, ['for_sure_this_is_not_an_existing_locale']))
+        # The original spelling here, "for_sure_this_is_not_an_existing_locale",
+        # is accidentally detected as existing by the Windows UCRT.
+        # https://developercommunity.visualstudio.com/t/setlocale-succeeds-for-bogus-locale-names-in-older/1652241
+        # This is fixed in UCRT/Windows 10.0.18362.0.
+        self.assertFalse(dsl.hasAnyLocale(self.config, ['forsurethisisnotanexistinglocale']))
 
     def test_localization_program_doesnt_compile(self):
         compilerIndex = findIndex(self.config.substitutions, lambda x: x[0] == '%{cxx}')


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120546.411347.patch
Type: text/x-patch
Size: 1872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220225/3fe37dbc/attachment.bin>


More information about the libcxx-commits mailing list