diff options
author | Jordan Rose <jordan_rose@apple.com> | 2017-10-13 16:12:23 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2017-10-13 16:12:23 +0000 |
commit | e9bafbf37011514827bfe32bb81d3f4e59f206da (patch) | |
tree | 1b5ac16171633e94ba00fb8f88e6e2264a65da55 /utils/lit | |
parent | b5a710de5a6af31df873d0fbe32adb75c130254a (diff) |
lit.py: Add new %{shared_output(LABEL)} substitution
This refers to a temporary path that can be shared across all tests,
identified by a particular label. This can be used for things like
caches.
At the moment, the character set for the LABEL is limited to C
identifier characters, plus '-', '+', '=', and '.'. This is the same
set of characters currently allowed in REQUIRES clause identifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r-- | utils/lit/lit/TestRunner.py | 5 | ||||
-rw-r--r-- | utils/lit/lit/run.py | 8 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shared-output/lit.cfg | 5 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shared-output/primary.txt | 2 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shared-output/secondary.txt | 1 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shared-output/sub/sub.txt | 1 | ||||
-rw-r--r-- | utils/lit/tests/shared-output.py | 13 |
7 files changed, 35 insertions, 0 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py index b874f9ee61b..6680bd0312c 100644 --- a/utils/lit/lit/TestRunner.py +++ b/utils/lit/lit/TestRunner.py @@ -829,6 +829,9 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False): sourcepath = test.getSourcePath() sourcedir = os.path.dirname(sourcepath) + sharedOutputDir = os.path.join(test.suite.exec_root, 'Output', 'Shared') + sharedOutputDir += os.path.sep + # Normalize slashes, if requested. if normalize_slashes: sourcepath = sourcepath.replace('\\', '/') @@ -849,6 +852,8 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False): ('%t', tmpName), ('%basename_t', baseName), ('%T', tmpDir), + ('%{shared_output\(([-+=._a-zA-Z0-9]+)\)}', + '%s\\1.tmp' % (sharedOutputDir,)), ('#_MARKER_#', '%')]) # "%/[STpst]" should be normalized. diff --git a/utils/lit/lit/run.py b/utils/lit/lit/run.py index a4a21234fa3..92dfed97d75 100644 --- a/utils/lit/lit/run.py +++ b/utils/lit/lit/run.py @@ -1,4 +1,5 @@ import os +import shutil import sys import threading import time @@ -136,6 +137,13 @@ class Run(object): return True win32api.SetConsoleCtrlHandler(console_ctrl_handler, True) + # Make fresh shared output directories. + suites = set(test.suite for test in self.tests) + for suite in suites: + shared_dir = os.path.join(suite.exec_root, 'Output', 'Shared') + shutil.rmtree(shared_dir, ignore_errors=True) + lit.util.mkdir_p(shared_dir) + # Save the display object on the runner so that we can update it from # our task completion callback. self.display = display diff --git a/utils/lit/tests/Inputs/shared-output/lit.cfg b/utils/lit/tests/Inputs/shared-output/lit.cfg new file mode 100644 index 00000000000..121bff7ec98 --- /dev/null +++ b/utils/lit/tests/Inputs/shared-output/lit.cfg @@ -0,0 +1,5 @@ +import lit.formats +config.name = 'shared-output' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() +config.test_source_root = os.path.dirname(os.path.realpath(__file__)) diff --git a/utils/lit/tests/Inputs/shared-output/primary.txt b/utils/lit/tests/Inputs/shared-output/primary.txt new file mode 100644 index 00000000000..7da1deeaea6 --- /dev/null +++ b/utils/lit/tests/Inputs/shared-output/primary.txt @@ -0,0 +1,2 @@ +RUN: echo "primary" >> %{shared_output(SHARED)} +RUN: echo "other" >> %{shared_output(OTHER)} diff --git a/utils/lit/tests/Inputs/shared-output/secondary.txt b/utils/lit/tests/Inputs/shared-output/secondary.txt new file mode 100644 index 00000000000..c706a597eca --- /dev/null +++ b/utils/lit/tests/Inputs/shared-output/secondary.txt @@ -0,0 +1 @@ +RUN: echo "secondary" >> %{shared_output(SHARED)} diff --git a/utils/lit/tests/Inputs/shared-output/sub/sub.txt b/utils/lit/tests/Inputs/shared-output/sub/sub.txt new file mode 100644 index 00000000000..4418b348723 --- /dev/null +++ b/utils/lit/tests/Inputs/shared-output/sub/sub.txt @@ -0,0 +1 @@ +RUN: echo "sub" >> %{shared_output(SHARED)} diff --git a/utils/lit/tests/shared-output.py b/utils/lit/tests/shared-output.py new file mode 100644 index 00000000000..9f616f27810 --- /dev/null +++ b/utils/lit/tests/shared-output.py @@ -0,0 +1,13 @@ +# RUN: rm -rf %t && mkdir -p %t +# RUN: echo 'lit_config.load_config(config, "%{inputs}/shared-output/lit.cfg")' > %t/lit.site.cfg +# RUN: %{lit} %t +# RUN: FileCheck %s < %t/Output/Shared/SHARED.tmp +# RUN: FileCheck -check-prefix=NEGATIVE %s < %t/Output/Shared/SHARED.tmp +# RUN: FileCheck -check-prefix=OTHER %s < %t/Output/Shared/OTHER.tmp + +# CHECK-DAG: primary +# CHECK-DAG: secondary +# CHECK-DAG: sub + +# NEGATIVE-NOT: other +# OTHER: other |