Skip to content

Commit d14d4e2

Browse files
committed
test/lit.cfg: add a new substitution '%FileCheck'
'%FileCheck' removes absolute paths of the source and build directory from the input. Overwhelming majority of tests don't intend to match these paths. Also add a substitution '%raw-FileCheck' that does not sanitize the input.
1 parent c80b70f commit d14d4e2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

docs/Testing.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ Other substitutions:
358358
* ``%{python}``: run the same Python interpreter that's being used to run the
359359
current ``lit`` test.
360360

361+
* ``FileCheck``: like the LLVM ``FileCheck`` utility, but occurrences of full
362+
paths to the source and build directories in the input text are replaced with
363+
path-independent constants.
364+
365+
* ``%raw-FileCheck``: the LLVM ``FileCheck`` utility.
366+
361367
When writing a test where output (or IR, SIL) depends on the bitness of the
362368
target CPU, use this pattern::
363369

test/lit.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,9 @@ config.substitutions.append(('%target-resilience-test', config.target_resilience
998998
config.substitutions.append(('%llvm-profdata', config.llvm_profdata))
999999
config.substitutions.append(('%llvm-cov', config.llvm_cov))
10001000

1001+
config.substitutions.append(('\bFileCheck\b', 'sed -e \'s@%s@BUILD_DIR@\' -e \'s@%s@SOURCE_DIR@\' | FileCheck' % (swift_obj_root, config.swift_src_root)))
1002+
config.substitutions.append(('%raw-FileCheck', 'FileCheck'))
1003+
10011004
# If static stdlib is present, enable static stdlib tests
10021005
static_stdlib_path = os.path.join(os.path.join(config.swift_lib_dir,"swift_static"), config.target_sdk_name)
10031006
libswiftCore_path = os.path.join(static_stdlib_path,"libswiftCore.a")

0 commit comments

Comments
 (0)