[llvm] r272365 - [lit] Only gather redirected files for command failures.

Daniel Dunbar via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 9 21:17:31 PDT 2016


Author: ddunbar
Date: Thu Jun  9 23:17:30 2016
New Revision: 272365

URL: http://llvm.org/viewvc/llvm-project?rev=272365&view=rev
Log:
[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.

Modified:
    llvm/trunk/utils/lit/lit/TestRunner.py

Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=272365&r1=272364&r2=272365&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Thu Jun  9 23:17:30 2016
@@ -396,17 +396,18 @@ def _executeShCmd(cmd, shenv, results, t
         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(),




More information about the llvm-commits mailing list