-# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
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:
-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
# 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):
testPath = os.path.join(appliPath, __testSubDir)
command = ["ctest"] + args
- res, out, err = __runTest(command, testPath)
+ res = __runTest(command, testPath)
sys.exit(res)
#