Changeset: b6b1ac8dca39 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b6b1ac8dca39
Modified Files:
        testing/Mtest.py.in
        testing/process.py
Branch: Jan2022
Log Message:

Get Mtest.py --single-in-memory working.


diffs (99 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1358,6 +1358,8 @@ def PerformDir(env, testdir, testlist, a
                         if inmem:
                             cmd = splitcommand(env['exe']['mserver5'][1]) + 
['--set', 'gdk_dbname=%s' % TSTDB, '--in-memory'] + mserver5_opts + options
                             pollfile = None
+                            cmd.append('--set')
+                            
cmd.append('gdk_dbtrace={}'.format(os.path.join(LogDBdir, 'mdbtrace.log')))
                         else:
                             cmd = splitcommand(env['exe']['mserver5'][1]) + 
['--dbpath=%s' % LogDBdir] + mserver5_opts + options
                             pollfile = os.path.join(LogDBdir, '.started')
@@ -1372,7 +1374,8 @@ def PerformDir(env, testdir, testlist, a
                                             openutf8(os.path.join(TSTTRGDIR, 
'SingleServer.out'), 'a'),
                                             openutf8(os.path.join(TSTTRGDIR, 
'SingleServer.err'), 'a'),
                                             0,
-                                            pollfile)
+                                            pollfile,
+                                            inmem)
                         os.chdir(TSTTRGDIR)
                         pSrvr.LaunchIt()
                         if pSrvr.port is None:
@@ -2486,7 +2489,7 @@ def killProc(proc, outfile = None, cmd =
         killchildren(proc.pid)
 
 class ServerClass:
-    def __init__(self, cmd, TestOut, TestErr, TimeOut, pollfile):
+    def __init__(self, cmd, TestOut, TestErr, TimeOut, pollfile, inmem=False):
         self.proc = None
         self.timer = None
         self.outfile = TestOut
@@ -2496,6 +2499,7 @@ class ServerClass:
         self.cmd = cmd
         self.timeout = TimeOut
         self.pollfile = pollfile
+        self.inmem = inmem
 
     def poll(self):
         return self.proc.poll()
@@ -2511,6 +2515,8 @@ class ServerClass:
         self.proc.wait()
         t.cancel()
         self.code = returnCode(self.proc, self.errfile)
+        if self.pollfile is None:
+            self.outfile.write(self.proc.stdout.read())
         self.outfile.close()
         self.errfile.close()
 
@@ -2523,22 +2529,25 @@ class ServerClass:
         if procdebug:
             print('LaunchIt: starting process "%s" (inpipe)\n' % '" 
"'.join(self.cmd))
         setpgrp = True
-        if self.pollfile:
+        outfile = self.outfile
+        if self.inmem:
+            outfile = process.PIPE
+        elif self.pollfile:
             try:
                 os.unlink(self.pollfile)
             except OSError:
                 pass
         else:
-            self.outfile = process.PIPE
+            outfile = process.PIPE
         if os.name == "nt":
-            proc = process.Popen(self.cmd, stdin=open(os.devnull), 
stdout=self.outfile,
+            proc = process.Popen(self.cmd, stdin=open(os.devnull), 
stdout=outfile,
                                  stderr=self.errfile, text=True,
                                  
creationflags=process.CREATE_NEW_PROCESS_GROUP)
         else:
-            proc = process.Popen(self.cmd, stdin=open(os.devnull), 
stdout=self.outfile,
+            proc = process.Popen(self.cmd, stdin=open(os.devnull), 
stdout=outfile,
                                  stderr=self.errfile, text=True)
         # maybe buffer output as it comes to avoid deadlock
-        if self.outfile == process.PIPE:
+        if outfile == process.PIPE:
             proc.stdout = process._BufferedPipe(proc.stdout)
         if self.errfile == process.PIPE:
             proc.stderr = process._BufferedPipe(proc.stderr)
@@ -2571,6 +2580,7 @@ class ServerClass:
                 line = proc.stdout.readline()
                 if not line:
                     break
+                self.outfile.write(line)
                 if 'MonetDB/SQL module loaded' in line:
                     break
                 res = mapiportre.search(line)
diff --git a/testing/process.py b/testing/process.py
--- a/testing/process.py
+++ b/testing/process.py
@@ -95,7 +95,7 @@ class _BufferedPipe:
         w = 0
         first = True
         while True:
-            c = fh.read(1024)
+            c = fh.readline()
             if first:
                 if type(c) is type(b''):
                     self._empty = b''
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to