llvm.org GIT mirror llvm / 434c834
[lit] Only gather redirected files for command failures. - The intended use of this was just in diagnostics, so we shouldn't pay the cost of reading these all the time. - This will avoid including the full output of each command in tests which fail, but the most important use case for this was to gather the output of the specific command which failed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272365 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 4 years ago
1 changed file(s) with 11 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
395395 except:
396396 err = str(err)
397397
398 # Gather the redirected output files.
398 # Gather the redirected output files for failed commands.
399399 output_files = []
400 for (name, mode, f, path) in sorted(opened_files):
401 if path is not None and mode in ('w', 'a'):
402 try:
403 with open(path, 'rb') as f:
404 data = f.read()
405 except:
406 data = None
407 if data != None:
408 output_files.append((name, path, data))
400 if res != 0:
401 for (name, mode, f, path) in sorted(opened_files):
402 if path is not None and mode in ('w', 'a'):
403 try:
404 with open(path, 'rb') as f:
405 data = f.read()
406 except:
407 data = None
408 if data != None:
409 output_files.append((name, path, data))
409410
410411 results.append(ShellCommandResult(
411412 cmd.commands[i], out, err, res, timeoutHelper.timeoutReached(),