[PATCH] D35857: [lit] Fix UnboundLocalError for invalid shtest redirects

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 25 14:35:15 PDT 2017


mgorny created this revision.
Herald added a reviewer: modocache.

Replace the incorrect variable reference when invalid redirect is used.
This fixes the following issue:

  File "/usr/src/llvm/utils/lit/lit/TestRunner.py", line 316, in processRedirects
    raise InternalShellError(cmd, "Unsupported redirect: %r" % (r,))

UnboundLocalError: local variable 'r' referenced before assignment

which in turn broke shtest-shell.py and max-failures.py lit tests.

The breakage was introduced during refactoring in https://reviews.llvm.org/rL307310.


Repository:
  rL LLVM

https://reviews.llvm.org/D35857

Files:
  utils/lit/lit/TestRunner.py


Index: utils/lit/lit/TestRunner.py
===================================================================
--- utils/lit/lit/TestRunner.py
+++ utils/lit/lit/TestRunner.py
@@ -313,7 +313,7 @@
         elif op == ('<',):
             redirects[0] = [filename, 'r', None]
         else:
-            raise InternalShellError(cmd, "Unsupported redirect: %r" % (r,))
+            raise InternalShellError(cmd, "Unsupported redirect: %r" % ((op, filename),))
 
     # Open file descriptors in a second pass.
     std_fds = [None, None, None]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35857.108160.patch
Type: text/x-patch
Size: 532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170725/3a5601c4/attachment.bin>


More information about the llvm-commits mailing list