[libcxx-commits] [libcxx] 4e813bb - [libc++] Make sure tests are run in a unique directory

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 10 13:19:37 PDT 2020


Author: Louis Dionne
Date: 2020-06-10T16:19:10-04:00
New Revision: 4e813bbdf335626a741398314709a535ef52fe8e

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

LOG: [libc++] Make sure tests are run in a unique directory

This will allow simplifying executors by always just copying the whole
%T, and assuming that all file dependencies are contained in it.

Superseeds https://reviews.llvm.org/D78245, which tried to make %T unique
in Lit, but which encountered push back.

Added: 
    libcxx/test/libcxx/selftest/newformat/tmpdir-exists.sh.cpp

Modified: 
    libcxx/utils/libcxx/test/dsl.py
    libcxx/utils/libcxx/test/newformat.py

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/selftest/newformat/tmpdir-exists.sh.cpp b/libcxx/test/libcxx/selftest/newformat/tmpdir-exists.sh.cpp
new file mode 100644
index 000000000000..7f9e69d269d6
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/newformat/tmpdir-exists.sh.cpp
@@ -0,0 +1,11 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Make sure that the directory represented by %T exists when we run the test.
+
+// RUN: test -d %T

diff  --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index d449c60359bf..f3add443093b 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -33,7 +33,7 @@ def __init__(self):
       self.isWindows = platform.system() == 'Windows'
       self.maxIndividualTestTime = 0
   litConfig = FakeLitConfig()
-  _, tmpBase = lit.TestRunner.getTempPaths(test)
+  _, tmpBase = libcxx.test.newformat._getTempPaths(test)
   execDir = os.path.dirname(test.getExecPath())
   if not os.path.exists(execDir):
     os.makedirs(execDir)

diff  --git a/libcxx/utils/libcxx/test/newformat.py b/libcxx/utils/libcxx/test/newformat.py
index 0bb3be3369ba..43b11a40f0a4 100644
--- a/libcxx/utils/libcxx/test/newformat.py
+++ b/libcxx/utils/libcxx/test/newformat.py
@@ -27,6 +27,19 @@ def _supportsVerify(config):
     result = subprocess.call(command, shell=True, stdout=devNull, stderr=devNull)
     return result == 0
 
+def _getTempPaths(test):
+    """
+    Return the values to use for the %T and %t substitutions, respectively.
+
+    The 
diff erence between this and Lit's default behavior is that we guarantee
+    that %T is a path unique to the test being run.
+    """
+    tmpDir, _ = lit.TestRunner.getTempPaths(test)
+    _, testName = os.path.split(test.getExecPath())
+    tmpDir = os.path.join(tmpDir, testName + '.dir')
+    tmpBase = os.path.join(tmpDir, 't')
+    return tmpDir, tmpBase
+
 def parseScript(test, preamble, fileDependencies):
     """
     Extract the script from a test, with substitutions applied.
@@ -47,7 +60,7 @@ def parseScript(test, preamble, fileDependencies):
     """
 
     # Get the default substitutions
-    tmpDir, tmpBase = lit.TestRunner.getTempPaths(test)
+    tmpDir, tmpBase = _getTempPaths(test)
     useExternalSh = True
     substitutions = lit.TestRunner.getDefaultSubstitutions(test, tmpDir, tmpBase,
                                                            normalize_slashes=useExternalSh)
@@ -311,6 +324,6 @@ def _executeShTest(self, test, litConfig, steps, fileDependencies=None):
         if litConfig.noExecute:
             return lit.Test.Result(lit.Test.XFAIL if test.isExpectedToFail() else lit.Test.PASS)
         else:
-            _, tmpBase = lit.TestRunner.getTempPaths(test)
+            _, tmpBase = _getTempPaths(test)
             useExternalSh = True
             return lit.TestRunner._runShTest(test, litConfig, useExternalSh, script, tmpBase)


        


More information about the libcxx-commits mailing list