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

afa at codespeak.net afa at codespeak.net
Mon Nov 30 17:57:52 CET 2009


Author: afa
Date: Mon Nov 30 17:57:51 2009
New Revision: 69776

Modified:
   pypy/build/testrunner/runner.py
   pypy/build/testrunner/test/test_runner.py
Log:
Fix testrunner on Windows:

- prefix the executable with the current dir, as the docs for subprocess say
     """this directory is not considered when searching the executable, 
     so you can’t specify the program’s path relative to cwd."""

- when win32api is not installed, use ctypes to access the kernel API
  and kill the running process.
--Cette ligne, et les suivantes ci-dessous, seront ignorées--

M    test/test_runner.py
M    runner.py


Modified: pypy/build/testrunner/runner.py
==============================================================================
--- pypy/build/testrunner/runner.py	(original)
+++ pypy/build/testrunner/runner.py	Mon Nov 30 17:57:51 2009
@@ -8,7 +8,11 @@
         import win32api, pywintypes
     except ImportError:
         def _kill(pid, sig):
-            print >>sys.stderr, "no process killing support without pywin32"
+            import ctypes
+            winapi = ctypes.windll.kernel32
+            proch = winapi.OpenProcess(PROCESS_TERMINATE, 0, pid)
+            winapi.TerminateProcess(proch, 1) == 1
+            winapi.CloseHandle(proch)
     else:
         def _kill(pid, sig):
             try:
@@ -18,6 +22,7 @@
             except pywintypes.error, e:
                 pass
 
+    SIGKILL = SIGTERM = 0
     READ_MODE = 'rU'
     WRITE_MODE = 'wb'
 else:
@@ -26,6 +31,9 @@
             os.kill(pid, sig)
         except OSError:
             pass
+
+    SIGKILL = signal.SIGKILL
+    SIGTERM = signal.SIGTERM
     READ_MODE = 'r'
     WRITE_MODE = 'w'
 
@@ -56,11 +64,11 @@
                 tnow = time.time()
                 if (tnow-t0) > timeout:
                     if timedout:
-                        _kill(p.pid, signal.SIGKILL)
+                        _kill(p.pid, SIGKILL)
                         return TIMEDOUT
                     else:
                         timedout = TIMEDOUT
-                        _kill(p.pid, signal.SIGTERM)
+                        _kill(p.pid, SIGTERM)
                 time.sleep(min(timeout, 10))
     finally:
         f.close()
@@ -81,10 +89,12 @@
 
 def execute_test(cwd, test, out, logfname, interp, test_driver,
                  do_dry_run=False, timeout=None):
-    args = interp+test_driver
+    args = interp + test_driver
     args += ['--resultlog=%s' % logfname, test]
 
     args = map(str, args)
+    args[0] = os.path.join(str(cwd), args[0])
+
     if do_dry_run:
         runfunc = dry_run
     else:

Modified: pypy/build/testrunner/test/test_runner.py
==============================================================================
--- pypy/build/testrunner/test/test_runner.py	(original)
+++ pypy/build/testrunner/test/test_runner.py	Mon Nov 30 17:57:51 2009
@@ -72,7 +72,7 @@
                                   test_driver=['driver', 'darg'],
                                   timeout='secs')
 
-        expected = ['INTERP', 'IARG', 
+        expected = ['/wd' + os.sep + 'INTERP', 'IARG',
                     'driver', 'darg',
                     '--resultlog=LOGFILE',
                     'test_one']



More information about the Pypy-commit mailing list