llvm.org GIT mirror llvm / e9bafbf
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 Jordan Rose 1 year, 10 months ago
9 changed file(s) with 53 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
394394 :program:`lit` provides various patterns that can be used with the RUN command.
395395 These are defined in TestRunner.py. The base set of substitutions are:
396396
397 ========== ==============
398 Macro Substitution
399 ========== ==============
400 %s source path (path to the file currently being run)
401 %S source dir (directory of the file currently being run)
402 %p same as %S
403 %{pathsep} path separator
404 %t temporary file name unique to the test
405 %T temporary directory unique to the test
406 %% %
407 ========== ==============
397 ======================= ==============
398 Macro Substitution
399 ======================= ==============
400 %s source path (path to the file currently being run)
401 %S source dir (directory of the file currently being run)
402 %p same as %S
403 %{pathsep} path separator
404 %t temporary file name unique to the test
405 %T temporary directory unique to the test
406 %{shared_output(LABEL)} temporary file name, identified by "LABEL", shared across all tests
407 %% %
408 ======================= ==============
408409
409410 Other substitutions are provided that are variations on this base set and
410411 further substitution patterns can be defined by each test module. See the
463463
464464 Example: ``/home/user/llvm.build/test/MC/ELF/Output``
465465
466 ``%{shared_output(LABEL)}``
467 File path to a temporary file name shared across all tests, identified by
468 LABEL. This is useful as a cache for generated resources.
469
470 Example: ``/home/user/llvm.build/test/Output/Shared/LABEL.tmp``
471
466472 ``%{pathsep}``
467473
468474 Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
828828 sourcepath = test.getSourcePath()
829829 sourcedir = os.path.dirname(sourcepath)
830830
831 sharedOutputDir = os.path.join(test.suite.exec_root, 'Output', 'Shared')
832 sharedOutputDir += os.path.sep
833
831834 # Normalize slashes, if requested.
832835 if normalize_slashes:
833836 sourcepath = sourcepath.replace('\\', '/')
848851 ('%t', tmpName),
849852 ('%basename_t', baseName),
850853 ('%T', tmpDir),
854 ('%{shared_output\(([-+=._a-zA-Z0-9]+)\)}',
855 '%s\\1.tmp' % (sharedOutputDir,)),
851856 ('#_MARKER_#', '%')])
852857
853858 # "%/[STpst]" should be normalized.
0 import os
1 import shutil
12 import sys
23 import threading
34 import time
134135 abort_now()
135136 return True
136137 win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)
138
139 # Make fresh shared output directories.
140 suites = set(test.suite for test in self.tests)
141 for suite in suites:
142 shared_dir = os.path.join(suite.exec_root, 'Output', 'Shared')
143 shutil.rmtree(shared_dir, ignore_errors=True)
144 lit.util.mkdir_p(shared_dir)
137145
138146 # Save the display object on the runner so that we can update it from
139147 # our task completion callback.
0 import lit.formats
1 config.name = 'shared-output'
2 config.suffixes = ['.txt']
3 config.test_format = lit.formats.ShTest()
4 config.test_source_root = os.path.dirname(os.path.realpath(__file__))
0 RUN: echo "primary" >> %{shared_output(SHARED)}
1 RUN: echo "other" >> %{shared_output(OTHER)}
0 RUN: echo "secondary" >> %{shared_output(SHARED)}
0 RUN: echo "sub" >> %{shared_output(SHARED)}
0 # RUN: rm -rf %t && mkdir -p %t
1 # RUN: echo 'lit_config.load_config(config, "%{inputs}/shared-output/lit.cfg")' > %t/lit.site.cfg
2 # RUN: %{lit} %t
3 # RUN: FileCheck %s < %t/Output/Shared/SHARED.tmp
4 # RUN: FileCheck -check-prefix=NEGATIVE %s < %t/Output/Shared/SHARED.tmp
5 # RUN: FileCheck -check-prefix=OTHER %s < %t/Output/Shared/OTHER.tmp
6
7 # CHECK-DAG: primary
8 # CHECK-DAG: secondary
9 # CHECK-DAG: sub
10
11 # NEGATIVE-NOT: other
12 # OTHER: other