diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2017-07-13 19:26:27 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2017-07-13 19:26:27 +0000 |
commit | 92aa19c98134f0fdc7bfd652a396fc903408ac46 (patch) | |
tree | 9f27a6b50f772dc895191fc1fc0accaa7ba2a086 /utils/lit | |
parent | 720184846532b5b2af5de50de417e41069570f4d (diff) |
[lit] add a -vv option to echo all executed commands.
Debugging LIT scripts can be rather painful, as LIT directly does not
specify which line has failed.
Rather, FileCheck is expected to report the failing location, but it can
be often ambiguous if multiple commands are tested against the same
prefix. This change adds a -vv option, which echoes all output.
Then detecting the error becomes straightforward: last printed line is
the failing one.
Of course, it could be desired to try to get failing line number
directly from bash, but it involves excessive hacks on older bash
versions (cf.
https://stackoverflow.com/questions/24398691/how-to-get-the-real-line-number-of-a-failing-bash-command)
Differential Revision: https://reviews.llvm.org/D35330
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r-- | utils/lit/lit/LitConfig.py | 4 | ||||
-rw-r--r-- | utils/lit/lit/TestRunner.py | 2 | ||||
-rwxr-xr-x | utils/lit/lit/main.py | 12 |
3 files changed, 16 insertions, 2 deletions
diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py index 2b680846e17..2ef0a8f77ec 100644 --- a/utils/lit/lit/LitConfig.py +++ b/utils/lit/lit/LitConfig.py @@ -25,7 +25,8 @@ class LitConfig(object): params, config_prefix = None, maxIndividualTestTime = 0, maxFailures = None, - parallelism_groups = []): + parallelism_groups = [], + echo_all_commands = False): # The name of the test runner. self.progname = progname # The items to add to the PATH environment variable. @@ -64,6 +65,7 @@ class LitConfig(object): self.maxIndividualTestTime = maxIndividualTestTime self.maxFailures = maxFailures self.parallelism_groups = parallelism_groups + self.echo_all_commands = echo_all_commands @property def maxIndividualTestTime(self): diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py index 8260d381334..46bcac4b306 100644 --- a/utils/lit/lit/TestRunner.py +++ b/utils/lit/lit/TestRunner.py @@ -715,6 +715,8 @@ def executeScript(test, litConfig, tmpBase, commands, cwd): else: if test.config.pipefail: f.write('set -o pipefail;') + if litConfig.echo_all_commands: + f.write('set -x;') f.write('{ ' + '; } &&\n{ '.join(commands) + '; }') f.write('\n') f.close() diff --git a/utils/lit/lit/main.py b/utils/lit/lit/main.py index 530f962d336..f0162464ce3 100755 --- a/utils/lit/lit/main.py +++ b/utils/lit/lit/main.py @@ -199,6 +199,12 @@ def main_with_tmp(builtinParameters): format_group.add_argument("-v", "--verbose", dest="showOutput", help="Show test output for failures", action="store_true", default=False) + format_group.add_argument("-vv", "--echo-all-commands", + dest="echoAllCommands", + action="store_true", default=False, + help="Echo all commands as they are executed to stdout.\ + In case of failure, last command shown will be the\ + failing one.") format_group.add_argument("-a", "--show-all", dest="showAllOutput", help="Display all commandlines and output", action="store_true", default=False) @@ -303,6 +309,9 @@ def main_with_tmp(builtinParameters): if opts.maxFailures == 0: parser.error("Setting --max-failures to 0 does not have any effect.") + if opts.echoAllCommands: + opts.showOutput = True + inputs = args # Create the user defined parameters. @@ -338,7 +347,8 @@ def main_with_tmp(builtinParameters): config_prefix = opts.configPrefix, maxIndividualTestTime = maxIndividualTestTime, maxFailures = opts.maxFailures, - parallelism_groups = {}) + parallelism_groups = {}, + echo_all_commands = opts.echoAllCommands) # Perform test discovery. run = lit.run.Run(litConfig, |