llvm-project
55 строк · 2.2 Кб
1import lit
2
3# Use lit's internal shell to help guarantee test portability.
4config.test_format = lit.formats.ShTest(execute_external=False)
5
6# %ProtectFileCheckOutput should precede a FileCheck call if and only if the
7# call's textual output affects test results. It's usually easy to tell: just
8# look for redirection or piping of the FileCheck call's stdout or stderr.
9#
10# Examples:
11#
12# ; Test another program, using FileCheck to verify its textual output.
13# ; Only FileCheck's exit status affects test results, so a bare FileCheck
14# ; call is sufficient and more convenient for debugging.
15# ;
16# ; RUN: %t | FileCheck %s
17# ; CHECK: {{[0-9]+\.0}}
18#
19# ; Test FileCheck itself, but only examine its exit status, so a bare
20# ; FileCheck call is still sufficient and more convenient for debugging.
21# ;
22# ; RUN: FileCheck -input-file %s %s
23# ; CHECK: {{[0-9]+\.0}}
24# ; 5.0
25#
26# ; Check that the FileCheck trace is off by default. The first FileCheck
27# ; call's textual output affects test results, so it requires
28# ; %ProtectFileCheckOutput to be safe.
29# ;
30# ; RUN: %ProtectFileCheckOutput FileCheck -input-file %s %s 2>&1 \
31# ; RUN: | FileCheck -allow-empty -check-prefix QUIET %s
32# ;
33# ; CHECK: {{[0-9]+\.0}}
34# ; 5.0
35# ; QUIET-NOT: expected string found in input
36#
37# ; Check that the FileCheck trace is on when FILECHECK_OPTS=-v.
38# ; FILECHECK_OPTS must be set after %ProtectFileCheckOutput, which clears
39# ; FILECHECK_OPTS beforehand.
40# ;
41# ; RUN: %ProtectFileCheckOutput FILECHECK_OPTS=-v \
42# ; RUN: FileCheck -dump-input=never -input-file %s %s 2>&1 \
43# ; RUN: | FileCheck -check-prefix TRACE %s
44# ;
45# ; CHECK: {{[0-9]+\.0}}
46# ; 5.0
47# ; TRACE: expected string found in input
48#
49# %ProtectFileCheckOutput's purpose is to ensure correct test results when
50# developers set FileCheck environment variables (e.g.,
51# FILECHECK_OPTS=-dump-input=fail) to tweak the output of FileCheck while
52# debugging tests. If a developer sets values that affect FileCheck's exit
53# status (e.g., FILECHECK_OPTS=-strict-whitespace), he shouldn't be surprised
54# that test results throughout all test suites are affected.
55config.substitutions.append(("%ProtectFileCheckOutput", "env -u FILECHECK_OPTS"))
56