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

Modified Files:
      Tag: Aug2009
        connect_crash.SF-1436626.py 
        mdb_starts_with_sql_debug_64.SF-1999354.py 
        set_a_new_user_password.SF-1844050.py 
        set_sql_debug_64__breaking_the_DB.SF-1906287.py 
Log Message:
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.


U set_sql_debug_64__breaking_the_DB.SF-1906287.py
Index: set_sql_debug_64__breaking_the_DB.SF-1906287.py
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/test/BugTracker/Tests/set_sql_debug_64__breaking_the_DB.SF-1906287.py,v
retrieving revision 1.5.8.1
retrieving revision 1.5.8.2
diff -u -d -r1.5.8.1 -r1.5.8.2
--- set_sql_debug_64__breaking_the_DB.SF-1906287.py     19 Aug 2009 13:57:26 
-0000      1.5.8.1
+++ set_sql_debug_64__breaking_the_DB.SF-1906287.py     9 Oct 2009 13:37:32 
-0000       1.5.8.2
@@ -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>')
@@ -12,18 +17,18 @@
     srvcmd_ = clean_ports(srvcmd,str(port),os.getenv('XRPCPORT'))
     sys.stderr.write('#mserver: "%s"\n' % (srvcmd))
     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()
     time.sleep(2)                      # give server time to stop
 
 def client_load_file(clt, port, file):
     f = open(file, 'r')
     for line in f:
-        clt.write(line)
+        clt.stdin.write(line)
     f.close()
 
 
@@ -33,10 +38,10 @@
     sys.stderr.flush()
     sys.stderr.write('#client: "%s"\n' % (cltcmd))
     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)
 
 

U connect_crash.SF-1436626.py
Index: connect_crash.SF-1436626.py
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/test/BugTracker/Tests/connect_crash.SF-1436626.py,v
retrieving revision 1.5.8.1
retrieving revision 1.5.8.2
diff -u -d -r1.5.8.1 -r1.5.8.2
--- connect_crash.SF-1436626.py 9 Oct 2009 08:20:57 -0000       1.5.8.1
+++ connect_crash.SF-1436626.py 9 Oct 2009 13:37:32 -0000       1.5.8.2
@@ -1,4 +1,9 @@
-import subprocess, os, time
+import os, time
+try:
+    import subprocess
+except ImportError:
+    # use private copy for old Python versions
+    import MonetDBtesting.subprocess26 as subprocess
 
 def main():
     srvcmd = '%s --dbname "%s" --dbinit "include sql;"' % 
(os.getenv('MSERVER'),os.getenv('TSTDB'))

U set_a_new_user_password.SF-1844050.py
Index: set_a_new_user_password.SF-1844050.py
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/test/BugTracker/Tests/set_a_new_user_password.SF-1844050.py,v
retrieving revision 1.5.8.1
retrieving revision 1.5.8.2
diff -u -d -r1.5.8.1 -r1.5.8.2
--- set_a_new_user_password.SF-1844050.py       19 Aug 2009 13:57:26 -0000      
1.5.8.1
+++ set_a_new_user_password.SF-1844050.py       9 Oct 2009 13:37:32 -0000       
1.5.8.2
@@ -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,18 +22,18 @@
     srvcmd_ = clean_ports(srvcmd,str(port),os.getenv('XRPCPORT'))
     sys.stderr.write('#mserver: "%s"\n' % (srvcmd))
     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()
     time.sleep(2)                      # give server time to stop
 
 def client_load_file(clt, port, file):
     f = open(file, 'r')
     for line in f:
-        clt.write(line)
+        clt.stdin.write(line)
     f.close()
 
 
@@ -39,10 +44,10 @@
     sys.stderr.flush()
     sys.stderr.write('#client: "%s"\n' % (cltcmd_))
     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)
 
 

U mdb_starts_with_sql_debug_64.SF-1999354.py
Index: mdb_starts_with_sql_debug_64.SF-1999354.py
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/test/BugTracker/Tests/mdb_starts_with_sql_debug_64.SF-1999354.py,v
retrieving revision 1.4.6.1
retrieving revision 1.4.6.2
diff -u -d -r1.4.6.1 -r1.4.6.2
--- mdb_starts_with_sql_debug_64.SF-1999354.py  19 Aug 2009 13:57:26 -0000      
1.4.6.1
+++ mdb_starts_with_sql_debug_64.SF-1999354.py  9 Oct 2009 13:37:32 -0000       
1.4.6.2
@@ -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>')
@@ -12,18 +17,18 @@
     srvcmd_ = clean_ports(srvcmd,str(port),os.getenv('XRPCPORT'))
     sys.stderr.write('#mserver: "%s"\n' % (srvcmd))
     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()
     time.sleep(2)                      # give server time to stop
 
 def client_load_file(clt, port, file):
     f = open(file, 'r')
     for line in f:
-        clt.write(line)
+        clt.stdin.write(line)
     f.close()
 
 
@@ -33,10 +38,10 @@
     sys.stderr.flush()
     sys.stderr.write('#client: "%s"\n' % (cltcmd))
     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)
 
 


------------------------------------------------------------------------------
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