Salome HOME
add options-help get from launcher
[modules/kernel.git] / bin / runTests.py
index 7384e8554b06ef24e396013291427a50b02cc136..d1d5656c3df90844c9b657558b6164df83d48672 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2015-2024  CEA, EDF, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,9 @@ import sys
 import select
 import subprocess
 
-def __configureTests(args=[], exe=None):
+def __configureTests(args=None, exe=None):
+  if args is None:
+    args = []
   if exe:
       usage = "Usage: %s [options]"%exe
   else:
@@ -33,6 +35,10 @@ Principal options are:
     -h,--help
         Show this help message and exit.
 
+    --print-labels
+        Print the list of all labels associated with the test set.
+        This option will not run any tests.
+
     -V,--verbose
         Enable verbose output from tests.
     -VV,--extra-verbose
@@ -59,7 +65,7 @@ For complete description of available options, pleaser refer to ctest documentat
     return []
 
   if args[0] in ["-h", "--help"]:
-    print usage + epilog
+    print(usage + epilog)
     sys.exit(0)
 
   return args
@@ -68,36 +74,6 @@ 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=1)
-  stdout = []
-  stderr = []
-
-  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
-      pass
-
-    if p.poll() != None:
-      break
-    pass
-
-  return p.returncode, "".join(stdout), "".join(stderr)
-#
-
 def runTests(args, exe=None):
   args = __configureTests(args, exe)
 
@@ -108,7 +84,7 @@ def runTests(args, exe=None):
   testPath = os.path.join(appliPath, __testSubDir)
 
   command = ["ctest"] + args
-  res, out, err = __runTest(command, testPath)
-
-  sys.exit(res)
+  p = subprocess.Popen(command, cwd=testPath)
+  p.communicate()
+  return p.returncode
 #