[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Python sub-process error checking

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2003-04-08 01:04:49 CEST

Hello

The following patch makes the regression tests raise an error if a
process started by run_command crashes. This results in better error
checking on Unix, a command that crashes will be detected
automatically rather than relying on the crash being detected by the
absence of some effect. The disadvantage is that if a test is written
that relies on this new behaviour then it may not be effective on
Windows, it may pass when it should fail.

So, is this a good idea?

Better error checking on Unix platforms. Based on an old patch
from William Uther <will+@cs.cmu.edu>.

* subversion/tests/clients/cmdline/svntest/main.py (run_command): Use
  Popen3 on POSIX platforms to detect commands that crash.

Index: subversion/tests/clients/cmdline/svntest/main.py
===================================================================
--- subversion/tests/clients/cmdline/svntest/main.py (revision 5578)
+++ subversion/tests/clients/cmdline/svntest/main.py (working copy)
@@ -25,6 +25,9 @@
 import copy # for deepcopy()
 import time # for time()
 
+if os.name == 'posix':
+ import popen2
+
 from svntest import Failure
 from svntest import testcase
 from svntest import wc
@@ -229,11 +232,26 @@
     mode = 't'
 
   start = time.time()
- infile, outfile, errfile = os.popen3(command + args, mode)
+ if os.name == 'posix':
+ child = popen2.Popen3(command + args, 1)
 
- stdout_lines = outfile.readlines()
- stderr_lines = errfile.readlines()
+ stdout_lines = child.fromchild.readlines()
+ stderr_lines = child.childerr.readlines()
+ result = child.wait()
+ if os.WIFSIGNALED(result):
+ raise Failure("Signal " + str(os.WTERMSIG(result)) + " from " \
+ + os.path.basename(command) + args)
 
+ outfile = child.fromchild
+ infile = child.tochild
+ errfile = child.childerr
+
+ else:
+ infile, outfile, errfile = os.popen3(command + args, mode)
+
+ stdout_lines = outfile.readlines()
+ stderr_lines = errfile.readlines()
+
   outfile.close()
   infile.close()
   errfile.close()

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Apr 8 01:05:37 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.