[lit] Print negative exit codes on Windows in hex
authorReid Kleckner <rnk@google.com>
Mon, 7 Nov 2016 21:06:20 +0000 (21:06 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 7 Nov 2016 21:06:20 +0000 (21:06 +0000)
Negative exit codes are usually exceptions. They're easier to recognize
in hex. Compare -1073741502 to 0xc0000142.

llvm-svn: 286150

llvm/utils/lit/lit/TestRunner.py

index b242f8f..8e780a2 100644 (file)
@@ -555,8 +555,14 @@ def executeScriptInternal(test, litConfig, tmpBase, commands, cwd):
 
         # Show the error conditions:
         if result.exitCode != 0:
-            out += "error: command failed with exit status: %d\n" % (
-                result.exitCode,)
+            # On Windows, a negative exit code indicates a signal, and those are
+            # easier to recognize or look up if we print them in hex.
+            if litConfig.isWindows and result.exitCode < 0:
+                codeStr = hex(int(result.exitCode & 0xFFFFFFFF)).rstrip("L")
+            else:
+                codeStr = str(result.exitCode)
+            out += "error: command failed with exit status: %s\n" % (
+                codeStr,)
         if litConfig.maxIndividualTestTime > 0:
             out += 'error: command reached timeout: %s\n' % (
                 str(result.timeoutReached),)