[dragonegg] r188001 - [tests] Import executeCommand() from lit.

Daniel Dunbar daniel at zuster.org
Thu Aug 8 13:02:33 PDT 2013


Author: ddunbar
Date: Thu Aug  8 15:02:32 2013
New Revision: 188001

URL: http://llvm.org/viewvc/llvm-project?rev=188001&view=rev
Log:
[tests] Import executeCommand() from lit.

 - This is duplicating a small amount of code, but I don't want to consider
   lit's TestRunner module as part of its public API.

Modified:
    dragonegg/trunk/test/DETestRunner.py
    dragonegg/trunk/test/DEUtils.py

Modified: dragonegg/trunk/test/DETestRunner.py
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/DETestRunner.py?rev=188001&r1=188000&r2=188001&view=diff
==============================================================================
--- dragonegg/trunk/test/DETestRunner.py (original)
+++ dragonegg/trunk/test/DETestRunner.py Thu Aug  8 15:02:32 2013
@@ -1,7 +1,6 @@
 import os
 import StringIO
 import Test
-import TestRunner
 import Util
 import DEUtils
 
@@ -23,7 +22,7 @@ def describeFailure(output, cmd, out, er
 
 def compareCommands(cmds, args, cwd=None):
     def executeOne(cmd):
-        return TestRunner.executeCommand(cmd + args, cwd)
+        return DEUtils.executeCommand(cmd + args, cwd)
 
     results = map(executeOne, cmds)
     failed = False
@@ -59,7 +58,7 @@ def generateFortranModules(cmd, srcPath,
 
     # If the file compiles OK or isn't failing because of lacking modules then
     # there is no point in trying to generate modules.
-    out,err,exitCode = TestRunner.executeCommand(cmd + [srcPath], OutputDir)
+    out,err,exitCode = DEUtils.executeCommand(cmd + [srcPath], OutputDir)
     if exitCode == 0 or err is None or "Can't open module file" not in err:
         return
 
@@ -81,7 +80,7 @@ def generateFortranModules(cmd, srcPath,
         newFilesToCompile = []
         # Compile each file in turn.
         for path in filesToCompile:
-            out,err,exitCode = TestRunner.executeCommand(cmd + [path], OutputDir)
+            out,err,exitCode = DEUtils.executeCommand(cmd + [path], OutputDir)
             if exitCode != 0 and err is not None and "Can't open module file" in err:
                 # It failed to compile due to a missing module.  Remember it for
                 # the next round.

Modified: dragonegg/trunk/test/DEUtils.py
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/DEUtils.py?rev=188001&r1=188000&r2=188001&view=diff
==============================================================================
--- dragonegg/trunk/test/DEUtils.py (original)
+++ dragonegg/trunk/test/DEUtils.py Thu Aug  8 15:02:32 2013
@@ -1,6 +1,7 @@
 import os
+import signal
+import subprocess
 import tempfile
-import TestRunner
 
 suffixMap = {
   '.adb'   : 'ada',
@@ -28,6 +29,21 @@ suffixMap = {
   '.mm'    : 'objective-c++',
 }
 
+def executeCommand(command, cwd=None, env=None):
+    p = subprocess.Popen(command, cwd=cwd,
+                         stdin=subprocess.PIPE,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE,
+                         env=env, close_fds=True)
+    out,err = p.communicate()
+    exitCode = p.wait()
+
+    # Detect Ctrl-C in subprocess.
+    if exitCode == -signal.SIGINT:
+        raise KeyboardInterrupt
+
+    return out, err, exitCode
+
 def getLanguageForSuffix(suffix):
   return suffixMap[suffix]
 
@@ -47,8 +63,7 @@ def isLanguageSupported(language, compil
     script_dir = os.path.dirname(os.path.realpath(__file__))
     source = os.path.join(script_dir, 'e.class')
     # Java is supported if the class file compiles without error.
-    out,err,exitCode = TestRunner.executeCommand(args +
-                                                 [source, '-fuse-boehm-gc'])
+    out,err,exitCode = executeCommand(args + [source, '-fuse-boehm-gc'])
     return exitCode == 0
 
   if language == 'ada':
@@ -83,7 +98,7 @@ def isLanguageSupported(language, compil
   source.flush()
 
   # The language is supported if the file compiles without error.
-  out,err,exitCode = TestRunner.executeCommand(args + [source.name])
+  out,err,exitCode = executeCommand(args + [source.name])
   return exitCode == 0
 
 def getSupportedLanguages(compiler):





More information about the llvm-commits mailing list