[libc++] Quote the filesystem static env root in the source files instead of the...
authorLouis Dionne <ldionne@apple.com>
Mon, 30 Mar 2020 20:24:48 +0000 (16:24 -0400)
committerLouis Dionne <ldionne@apple.com>
Tue, 31 Mar 2020 13:40:01 +0000 (09:40 -0400)
Otherwise, trying to reproduce a failing filesystem test by copy-pasting
the command-line used and running that in the shell won't work, because
the shell will eat quoting around the define and we'll end up with a
non-stringized path in the .cpp file.

libcxx/test/std/input.output/filesystems/lit.local.cfg
libcxx/test/support/filesystem_test_helper.h
libcxx/test/support/test_macros.h

index 00e1492..00ec4c4 100644 (file)
@@ -8,7 +8,7 @@ if 'c++filesystem-disabled' in config.available_features:
   config.unsupported = True
 
 inputs = os.path.join(os.path.dirname(__file__), 'Inputs', 'static_test_env')
-config.test_format.addCompileFlags(config, '-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="{}"'.format(inputs))
+config.test_format.addCompileFlags(config, '-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT={}'.format(inputs))
 
 dynamic_helper = os.path.join(config.test_source_root, 'support', 'filesystem_dynamic_test_helper.py')
 assert os.path.isfile(dynamic_helper)
index 2c15606..d927787 100644 (file)
 
 namespace StaticEnv {
 
+static const fs::path Root = TEST_STRINGIZE(LIBCXX_FILESYSTEM_STATIC_TEST_ROOT);
+
 inline fs::path makePath(fs::path const& p) {
     // env_path is expected not to contain symlinks.
-    static const fs::path env_path = LIBCXX_FILESYSTEM_STATIC_TEST_ROOT;
+    fs::path const& env_path = Root;
     return env_path / p;
 }
 
-static const fs::path Root = LIBCXX_FILESYSTEM_STATIC_TEST_ROOT;
-
 static const fs::path TestFileList[] = {
         makePath("empty_file"),
         makePath("non_empty_file"),
index 6ab015d..6cbb7f0 100644 (file)
@@ -28,6 +28,9 @@
 #pragma GCC diagnostic ignored "-Wvariadic-macros"
 #endif
 
+#define TEST_STRINGIZE_IMPL(x) #x
+#define TEST_STRINGIZE(x) TEST_STRINGIZE_IMPL(x)
+
 #define TEST_CONCAT1(X, Y) X##Y
 #define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y)