]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
simplify test process call V7_8_0b1
authorCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 2 May 2016 08:20:55 +0000 (10:20 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 2 May 2016 08:53:32 +0000 (10:53 +0200)
bin/PortManager.py
bin/appliskel/salome
bin/runTests.py
bin/salomeContext.py

index a3b24a0f1c8e34f1c66ce9e7f6263753f168d47d..ff9eabfbef90cfe965d59091af22bf73840b5285 100644 (file)
@@ -90,11 +90,11 @@ def __isNetworkConnectionActiveOnPort(port):
   #        grep command is unavailable
   from subprocess import Popen, PIPE
   if sys.platform == "win32":
-    stdout, _ = Popen(['netstat','-a','-n','-p tcp'], stdout=PIPE).communicate()
+    out, _ = Popen(['netstat','-a','-n','-p tcp'], stdout=PIPE).communicate()
   else:
-    stdout, _ = Popen(['netstat','-ant'], stdout=PIPE).communicate()
+    out, _ = Popen(['netstat','-ant'], stdout=PIPE).communicate()
   import StringIO
-  buf = StringIO.StringIO(stdout)
+  buf = StringIO.StringIO(out)
   ports = buf.readlines()
   # search for TCP - LISTEN connections
   import re
index 5d56e01f207015c765e77573d14a6512496ebed1..90d5e1028a1ad5c8a8222d2aa086dac4406aadb2 100755 (executable)
@@ -58,7 +58,7 @@ def main(args):
         context.addToVariable(key,val)
 
     # Start SALOME, parsing command line arguments
-    (out, err), returncode = context.runSalome(args)
+    out, err, returncode = context.runSalome(args)
     if out:
       sys.stdout.write(out)
     if err:
index 23ccb38180eed21d603b61a55c940ea0714a7cd4..34a543f43d50b4671746a8af28193476cf358ccd 100644 (file)
@@ -74,34 +74,23 @@ For complete description of available options, pleaser refer to ctest documentat
 # tests must be in ${ABSOLUTE_APPLI_PATH}/${__testSubDir}/
 __testSubDir = "bin/salome/test"
 
-# Both display process stdout&stderr to console and capture them to variables
 def __runTest(command, workdir):
-  p = subprocess.Popen(command, cwd=workdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0)
-  stdout = []
-  stderr = []
+  p = subprocess.Popen(command, cwd=workdir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
   while True:
-    reads = [p.stdout.fileno(), p.stderr.fileno()]
-    ret = select.select(reads, [], [])
-
-    for fd in ret[0]:
-      if fd == p.stdout.fileno():
-        read = p.stdout.readline()
-        sys.stdout.write(read)
-        stdout.append(read)
-        pass
-      if fd == p.stderr.fileno():
-        read = p.stderr.readline()
-        sys.stderr.write(read)
-        stderr.append(read)
-        pass
+    try:
+      out = p.stdout.readline()
+      sys.stdout.write(out)
+    except: # raised IOError or OSError if output is empty
       pass
 
-    if p.poll() != None:
+    returncode = p.poll()
+    if not returncode is None:
+      sys.stdout.flush()
       break
     pass
 
-  return p.returncode, "".join(stdout), "".join(stderr)
+  return p.returncode
 #
 
 def runTests(args, exe=None):
@@ -114,7 +103,7 @@ def runTests(args, exe=None):
   testPath = os.path.join(appliPath, __testSubDir)
 
   command = ["ctest"] + args
-  res, out, err = __runTest(command, testPath)
+  res = __runTest(command, testPath)
 
   sys.exit(res)
 #
index 68d018ca37a8eb9973e77f60e0b58b38044ec0d9..00fa1bca86df5c2eb559bc4e86afd00097557bf0 100644 (file)
@@ -143,8 +143,8 @@ class SalomeContext:
     absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
     env_copy = os.environ.copy()
     proc = subprocess.Popen(['python', os.path.join(absoluteAppliPath,"bin","salome","salomeContext.py"), pickle.dumps(self), pickle.dumps(args)], shell=False, close_fds=True, env=env_copy)
-    msg = proc.communicate()
-    return msg, proc.returncode
+    out, err = proc.communicate()
+    return out, err, proc.returncode
   #
 
   """Append value to PATH environment variable"""