From 434c8349547c45e5433058465d775b0874ef5f59 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 10 Jun 2016 04:17:30 +0000 Subject: [PATCH] [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 --- utils/lit/lit/TestRunner.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py index 36d429204fd0..24d687280c43 100644 --- a/utils/lit/lit/TestRunner.py +++ b/utils/lit/lit/TestRunner.py @@ -396,17 +396,18 @@ def to_string(bytes): except: err = str(err) - # Gather the redirected output files. + # Gather the redirected output files for failed commands. output_files = [] - for (name, mode, f, path) in sorted(opened_files): - if path is not None and mode in ('w', 'a'): - try: - with open(path, 'rb') as f: - data = f.read() - except: - data = None - if data != None: - output_files.append((name, path, data)) + if res != 0: + for (name, mode, f, path) in sorted(opened_files): + if path is not None and mode in ('w', 'a'): + try: + with open(path, 'rb') as f: + data = f.read() + except: + data = None + if data != None: + output_files.append((name, path, data)) results.append(ShellCommandResult( cmd.commands[i], out, err, res, timeoutHelper.timeoutReached(),