Update of /cvsroot/monetdb/sql/src/test/Connections/Tests
In directory 
23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31061/src/test/Connections/Tests

Modified Files:
      Tag: Nov2009
        connections.py 
Log Message:
propagated changes of Friday Oct 09 2009
from the Aug2009 branch to the Nov2009 branch

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/10/09 - sjoerd: src/test/Connections/Tests/connections.py,1.10.10.1
  Replace use of os.popen by subprocess.Popen.  It seems on Windows the
  former doesn't inherit stdout which causes all these tests to fail
  there.
  
  In addition, some tests used some totally bizarre constructs.
  
  - If you create a process with a redirection from stdin (i.e. process
    < file), then it makes no sense to create a pipe to that process.
  - If you first replace the string port_num by some value and then to
    attempt to replace the string port_num5 by another value, then the
    second replace obviously has no effect.
  - If one process writes output to stdout (buffered!) and then starts a
    subprocess which also writes to the inherited stdout, then the
    buffered output of the parent process will come at the end, not
    where you might naively expect.
  - "<%s" % ('%s/../some-file' % dir) can be replaced with
    "<%s/../some-file" % dir (except that we should use os.path.join()
    here).
  
  Finally, cat | sed is not portable, so replaced that with a Python solution.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: connections.py
===================================================================
RCS file: /cvsroot/monetdb/sql/src/test/Connections/Tests/connections.py,v
retrieving revision 1.10
retrieving revision 1.10.12.1
diff -u -d -r1.10 -r1.10.12.1
--- connections.py      8 Feb 2008 22:49:39 -0000       1.10
+++ connections.py      9 Oct 2009 15:20:53 -0000       1.10.12.1
@@ -1,4 +1,9 @@
 import os, time, sys
+try:
+    import subprocess
+except ImportError:
+    # use private copy for old Python versions
+    import MonetDBtesting.subprocess26 as subprocess
 
 def clean_ports(cmd,mapiport,xrpcport):
     cmd = cmd.replace('--port=%s' % mapiport,'--port=<mapi_port>')
@@ -17,7 +22,7 @@
     sys.stderr.write('#remote mserver: "%s"\n' % (srvcmd))
     sys.stdout.flush()
     sys.stderr.flush()
-    srv = os.popen(srvcmd, 'w')
+    srv = subprocess.Popen(srvcmd, shell = True, stdin = subprocess.PIPE)
     time.sleep(5)                      # give server time to start
     return srv
 
@@ -31,19 +36,19 @@
     sys.stderr.write('#mserver: "%s"\n' % (srvcmd))
     sys.stdout.flush()
     sys.stderr.flush()
-    srv = os.popen(srvcmd, 'w')
+    srv = subprocess.Popen(srvcmd, shell = True, stdin = subprocess.PIPE)
     time.sleep(5)                      # give server time to start
     return srv
 
 def server_stop(srv):
-    srv.close()
+    srv.communicate()
 
 def client_load_file(clt, port, file):
     f = open(file, 'r')
     for line in f:
-        line = line.replace('port_num', str(port+1))
         line = line.replace('port_num5', str(port+2))
-        clt.write(line)
+        line = line.replace('port_num', str(port+1))
+        clt.stdin.write(line)
     f.close()
 
 
@@ -57,10 +62,10 @@
     sys.stderr.write('#client%d: "%s"\n' % (x,cltcmd))
     sys.stdout.flush()
     sys.stderr.flush()
-    clt = os.popen(cltcmd, 'w')
+    clt = subprocess.Popen(cltcmd, shell = True, stdin = subprocess.PIPE)
     port = int(os.getenv('MAPIPORT'))
     client_load_file(clt, port, file)
-    clt.close()
+    clt.communicate()
     return '%s ' % (lang)
 
 
@@ -69,9 +74,9 @@
     s += 1; srv = server_start(x,s,dbinit)
     s += 1; remote_srv = remote_server_start(x,s,dbinit)
     c = 0 ; h = ''
-    c += 1; h = client(x,s,c,dbinit,'SQL' , '%s/../connections_syntax.sql' % 
os.getenv('RELSRCDIR'))
-    c += 1; h = client(x,s,c,dbinit,'SQL' , '%s/../connections_semantic.sql' % 
os.getenv('RELSRCDIR'))
-    c += 1; h = client(x,s,c,dbinit,'SQL', 
'%s/../connections_default_values.sql' % os.getenv('RELSRCDIR'))
+    c += 1; h = client(x,s,c,dbinit,'SQL' , 
os.path.join(os.getenv('RELSRCDIR'),'..','connections_syntax.sql'))
+    c += 1; h = client(x,s,c,dbinit,'SQL' , 
os.path.join(os.getenv('RELSRCDIR'),'..','connections_semantic.sql'))
+    c += 1; h = client(x,s,c,dbinit,'SQL', 
os.path.join(os.getenv('RELSRCDIR'),'..','connections_default_values.sql'))
     server_stop(srv)
     server_stop(remote_srv)
 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to