[libcxx-commits] [libcxx] b632fe5 - [libc++] Quote the filesystem static env root in the source files instead of the command line

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 31 06:47:04 PDT 2020


Author: Louis Dionne
Date: 2020-03-31T09:40:01-04:00
New Revision: b632fe5a363488a377b22e1708c8b57d986d3fd8

URL: https://github.com/llvm/llvm-project/commit/b632fe5a363488a377b22e1708c8b57d986d3fd8
DIFF: https://github.com/llvm/llvm-project/commit/b632fe5a363488a377b22e1708c8b57d986d3fd8.diff

LOG: [libc++] Quote the filesystem static env root in the source files instead of the command line

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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/filesystems/lit.local.cfg b/libcxx/test/std/input.output/filesystems/lit.local.cfg
index 00e149254859..00ec4c454d7d 100644
--- a/libcxx/test/std/input.output/filesystems/lit.local.cfg
+++ b/libcxx/test/std/input.output/filesystems/lit.local.cfg
@@ -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)

diff  --git a/libcxx/test/support/filesystem_test_helper.h b/libcxx/test/support/filesystem_test_helper.h
index 2c15606cbec2..d92778793318 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -26,14 +26,14 @@
 
 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"),

diff  --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 6ab015db667a..6cbb7f0ccc16 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -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)
 


        


More information about the libcxx-commits mailing list