[pypy-svn] r60524 - in pypy/build/testrunner: . test

pedronis at codespeak.net pedronis at codespeak.net
Tue Dec 16 20:23:27 CET 2008


Author: pedronis
Date: Tue Dec 16 20:23:24 2008
New Revision: 60524

Modified:
   pypy/build/testrunner/runner.py
   pypy/build/testrunner/test/test_runner.py
Log:
don't hang and produce some error output if we fail to invoke the intepreter



Modified: pypy/build/testrunner/runner.py
==============================================================================
--- pypy/build/testrunner/runner.py	(original)
+++ pypy/build/testrunner/runner.py	Tue Dec 16 20:23:24 2008
@@ -24,12 +24,20 @@
         except OSError:
             pass
 
+RUNFAILED  = -1000
 TIMEDOUT = -999
 
 def run(args, cwd, out, timeout=None):
     f = out.open('w')
     try:
-        p = subprocess.Popen(args, cwd=str(cwd), stdout=f, stderr=f)
+        try:
+            p = subprocess.Popen(args, cwd=str(cwd), stdout=f, stderr=f)
+        except Exception, e:
+            f.write("Failed to run %s with cwd='%s' timeout=%s:\n"
+                    " %s\n"
+                    % (args, cwd, timeout, e))
+            return RUNFAILED
+
         if timeout is None:
             return p.wait()
         else:
@@ -89,6 +97,8 @@
                 msg = "Exit code %d." % exitcode
             elif exitcode == TIMEDOUT:
                 msg = "TIMEOUT"
+            elif exitcode == RUNFAILED:
+                msg = "Failed to run interp"
             else:
                 msg = "Killed by %s." % getsignalname(-exitcode)
             extralog = "! %s\n %s\n" % (test, msg)

Modified: pypy/build/testrunner/test/test_runner.py
==============================================================================
--- pypy/build/testrunner/test/test_runner.py	(original)
+++ pypy/build/testrunner/test/test_runner.py	Tue Dec 16 20:23:24 2008
@@ -270,6 +270,22 @@
         log_lines = log.getvalue().splitlines()
         assert log_lines[1] == ' TIMEOUT'
 
+    def test_run_wrong_interp(self):
+        log = cStringIO.StringIO()
+        out = cStringIO.StringIO()
+
+        run_param = runner.RunParam(self.one_test_dir)
+        run_param.interp=['wrong-interp']
+        run_param.parallel_runs = 3
+
+        testdirs = []
+        run_param.collect_testdirs(testdirs)
+        res = runner.execute_tests(run_param, testdirs, log, out)
+        assert res
+
+        log_lines = log.getvalue().splitlines()
+        assert log_lines[1] == ' Failed to run interp'
+
 class TestRunnerNoThreads(RunnerTests):
     with_thread = False
 



More information about the Pypy-commit mailing list