[libc++] Try to fix cross-loading of lit.local.cfg on Windows
authorLouis Dionne <ldionne@apple.com>
Tue, 27 Oct 2020 20:24:47 +0000 (16:24 -0400)
committerLouis Dionne <ldionne@apple.com>
Tue, 27 Oct 2020 20:28:29 +0000 (16:28 -0400)
On windows, the previous path replacement using forward slashes wouldn't
work, and so we'd end up including the same file again. We would do that
until we'd hit the recursion limit of the Python interpreter.

Instead, use `os.path` to properly replace without assuming a specific
path separator.

libcxx/test/libcxx/input.output/file.streams/lit.local.cfg
libcxx/test/libcxx/input.output/iostream.format/lit.local.cfg
libcxx/test/libcxx/input.output/iostream.objects/lit.local.cfg
libcxx/test/libcxx/input.output/iostreams.base/lit.local.cfg
libcxx/test/libcxx/input.output/stream.buffers/lit.local.cfg
libcxx/test/libcxx/input.output/string.streams/lit.local.cfg
libcxx/test/libcxx/localization/lit.local.cfg

index 1fc6b79..b89e35b 100644 (file)
@@ -1,4 +1,6 @@
 # Load the same local configuration as the corresponding one in libcxx/test/std
 import os
-localConfig = os.path.realpath(__file__).replace('/test/libcxx/', '/test/std/')
+inLibcxx = os.path.join('libcxx', 'test', 'libcxx')
+inStd = os.path.join('libcxx', 'test', 'std')
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
 config.load_from_path(localConfig, lit_config)
index 1fc6b79..b89e35b 100644 (file)
@@ -1,4 +1,6 @@
 # Load the same local configuration as the corresponding one in libcxx/test/std
 import os
-localConfig = os.path.realpath(__file__).replace('/test/libcxx/', '/test/std/')
+inLibcxx = os.path.join('libcxx', 'test', 'libcxx')
+inStd = os.path.join('libcxx', 'test', 'std')
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
 config.load_from_path(localConfig, lit_config)
index 1fc6b79..b89e35b 100644 (file)
@@ -1,4 +1,6 @@
 # Load the same local configuration as the corresponding one in libcxx/test/std
 import os
-localConfig = os.path.realpath(__file__).replace('/test/libcxx/', '/test/std/')
+inLibcxx = os.path.join('libcxx', 'test', 'libcxx')
+inStd = os.path.join('libcxx', 'test', 'std')
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
 config.load_from_path(localConfig, lit_config)
index 1fc6b79..b89e35b 100644 (file)
@@ -1,4 +1,6 @@
 # Load the same local configuration as the corresponding one in libcxx/test/std
 import os
-localConfig = os.path.realpath(__file__).replace('/test/libcxx/', '/test/std/')
+inLibcxx = os.path.join('libcxx', 'test', 'libcxx')
+inStd = os.path.join('libcxx', 'test', 'std')
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
 config.load_from_path(localConfig, lit_config)
index 1fc6b79..b89e35b 100644 (file)
@@ -1,4 +1,6 @@
 # Load the same local configuration as the corresponding one in libcxx/test/std
 import os
-localConfig = os.path.realpath(__file__).replace('/test/libcxx/', '/test/std/')
+inLibcxx = os.path.join('libcxx', 'test', 'libcxx')
+inStd = os.path.join('libcxx', 'test', 'std')
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
 config.load_from_path(localConfig, lit_config)
index 1fc6b79..b89e35b 100644 (file)
@@ -1,4 +1,6 @@
 # Load the same local configuration as the corresponding one in libcxx/test/std
 import os
-localConfig = os.path.realpath(__file__).replace('/test/libcxx/', '/test/std/')
+inLibcxx = os.path.join('libcxx', 'test', 'libcxx')
+inStd = os.path.join('libcxx', 'test', 'std')
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
 config.load_from_path(localConfig, lit_config)
index 1fc6b79..b89e35b 100644 (file)
@@ -1,4 +1,6 @@
 # Load the same local configuration as the corresponding one in libcxx/test/std
 import os
-localConfig = os.path.realpath(__file__).replace('/test/libcxx/', '/test/std/')
+inLibcxx = os.path.join('libcxx', 'test', 'libcxx')
+inStd = os.path.join('libcxx', 'test', 'std')
+localConfig = os.path.normpath(os.path.realpath(__file__)).replace(inLibcxx, inStd)
 config.load_from_path(localConfig, lit_config)