llvm.org GIT mirror llvm / 92aa19c
[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 George Karpenkov 2 years ago
4 changed file(s) with 23 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
7878
7979 Show more information on test failures, for example the entire test output
8080 instead of just the test result.
81
82 .. option:: -vv, --echo-all-commands
83
84 Echo all commands to stdout, as they are being executed.
85 This can be valuable for debugging test failures, as the last echoed command
86 will be the one which has failed.
87 This option implies ``--verbose``.
8188
8289 .. option:: -a, --show-all
8390
2424 params, config_prefix = None,
2525 maxIndividualTestTime = 0,
2626 maxFailures = None,
27 parallelism_groups = []):
27 parallelism_groups = [],
28 echo_all_commands = False):
2829 # The name of the test runner.
2930 self.progname = progname
3031 # The items to add to the PATH environment variable.
6364 self.maxIndividualTestTime = maxIndividualTestTime
6465 self.maxFailures = maxFailures
6566 self.parallelism_groups = parallelism_groups
67 self.echo_all_commands = echo_all_commands
6668
6769 @property
6870 def maxIndividualTestTime(self):
714714 else:
715715 if test.config.pipefail:
716716 f.write('set -o pipefail;')
717 if litConfig.echo_all_commands:
718 f.write('set -x;')
717719 f.write('{ ' + '; } &&\n{ '.join(commands) + '; }')
718720 f.write('\n')
719721 f.close()
198198 format_group.add_argument("-v", "--verbose", dest="showOutput",
199199 help="Show test output for failures",
200200 action="store_true", default=False)
201 format_group.add_argument("-vv", "--echo-all-commands",
202 dest="echoAllCommands",
203 action="store_true", default=False,
204 help="Echo all commands as they are executed to stdout.\
205 In case of failure, last command shown will be the\
206 failing one.")
201207 format_group.add_argument("-a", "--show-all", dest="showAllOutput",
202208 help="Display all commandlines and output",
203209 action="store_true", default=False)
301307
302308 if opts.maxFailures == 0:
303309 parser.error("Setting --max-failures to 0 does not have any effect.")
310
311 if opts.echoAllCommands:
312 opts.showOutput = True
304313
305314 inputs = args
306315
337346 config_prefix = opts.configPrefix,
338347 maxIndividualTestTime = maxIndividualTestTime,
339348 maxFailures = opts.maxFailures,
340 parallelism_groups = {})
349 parallelism_groups = {},
350 echo_all_commands = opts.echoAllCommands)
341351
342352 # Perform test discovery.
343353 run = lit.run.Run(litConfig,