1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00
llvm-mirror/test/FileCheck/lit.local.cfg
Joel E. Denny dd1fd5b646 [FileCheck] Make FILECHECK_OPTS useful for its test suite
Without this patch, `FILECHECK_OPTS` isn't propagated to FileCheck's
test suite so that `FILECHECK_OPTS` doesn't inadvertently affect test
results by affecting the output of FileCheck calls under test.  As a
result, `FILECHECK_OPTS` is useless for debugging FileCheck's test
suite.

In `llvm/test/FileCheck/lit.local.cfg`, this patch provides a new
subsitution, `%ProtectFileCheckOutput`, to address this problem for
both `FILECHECK_OPTS` and the deprecated
`FILECHECK_DUMP_INPUT_ON_FAILURE`.  The rest of the patch uses
`%ProtectFileCheckOutput` throughout the test suite

Fixes PR40284.

Reviewed By: probinson, thopre

Differential Revision: https://reviews.llvm.org/D65121
2019-11-21 18:01:12 -05:00

57 lines
2.2 KiB
INI

import lit
# Use lit's internal shell to help guarantee test portability.
config.test_format = lit.formats.ShTest(execute_external=False)
# %ProtectFileCheckOutput should precede a FileCheck call if and only if the
# call's textual output affects test results. It's usually easy to tell: just
# look for redirection or piping of the FileCheck call's stdout or stderr.
#
# Examples:
#
# ; Test another program, using FileCheck to verify its textual output.
# ; Only FileCheck's exit status affects test results, so a bare FileCheck
# ; call is sufficient and more convenient for debugging.
# ;
# ; RUN: %t | FileCheck %s
# ; CHECK: {{[0-9]+\.0}}
#
# ; Test FileCheck itself, but only examine its exit status, so a bare
# ; FileCheck call is still sufficient and more convenient for debugging.
# ;
# ; RUN: FileCheck -input-file %s %s
# ; CHECK: {{[0-9]+\.0}}
# ; 5.0
#
# ; Check that the FileCheck trace is off by default. The first FileCheck
# ; call's textual output affects test results, so it requires
# ; %ProtectFileCheckOutput to be safe.
# ;
# ; RUN: %ProtectFileCheckOutput FileCheck -input-file %s %s 2>&1 \
# ; RUN: | FileCheck -allow-empty -check-prefix QUIET %s
# ;
# ; CHECK: {{[0-9]+\.0}}
# ; 5.0
# ; QUIET-NOT: expected string found in input
#
# ; Check that the FileCheck trace is on when FILECHECK_OPTS=-v.
# ; FILECHECK_OPTS must be set after %ProtectFileCheckOutput, which clears
# ; FILECHECK_OPTS beforehand.
# ;
# ; RUN: %ProtectFileCheckOutput FILECHECK_OPTS=-v \
# ; RUN: FileCheck -input-file %s %s 2>&1 \
# ; RUN: | FileCheck -check-prefix TRACE %s
# ;
# ; CHECK: {{[0-9]+\.0}}
# ; 5.0
# ; TRACE: expected string found in input
#
# %ProtectFileCheckOutput's purpose is to ensure correct test results when
# developers set FileCheck environment variables (e.g.,
# FILECHECK_OPTS=-dump-input=fail) to tweak the output of FileCheck while
# debugging tests. If a developer sets values that affect FileCheck's exit
# status (e.g., FILECHECK_OPTS=-strict-whitespace), he shouldn't be surprised
# that test results throughout all test suites are affected.
config.substitutions.append(('%ProtectFileCheckOutput',
'env -u FILECHECK_OPTS -u FILECHECK_DUMP_INPUT_ON_FAILURE'))