1 # Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 def __configureTests(args=None, exe=None):
29 usage = "Usage: %s [options]"%exe
31 usage = "Usage: %prog [options]"
33 Run tests of SALOME components provided with application.\n
34 Principal options are:
36 Show this help message and exit.
39 Enable verbose output from tests.
41 Enable more verbose output from tests.
46 Show available tests (without running them).
48 -R <regex>, --tests-regex <regex>
49 Run tests matching regular expression.
50 -E <regex>, --exclude-regex <regex>
51 Exclude tests matching regular expression.
53 -L <regex>, --label-regex <regex>
54 Run tests with labels matching regular expression.
55 -LE <regex>, --label-exclude <regex>
56 Exclude tests with labels matching regular expression.
58 For complete description of available options, pleaser refer to ctest documentation.\n
63 if args[0] in ["-h", "--help"]:
70 # tests must be in ${ABSOLUTE_APPLI_PATH}/${__testSubDir}/
71 __testSubDir = "bin/salome/test"
73 # Both display process stdout&stderr to console and capture them to variables
74 def __runTest(command, workdir):
75 p = subprocess.Popen(command, cwd=workdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0)
80 reads = [p.stdout.fileno(), p.stderr.fileno()]
81 ret = select.select(reads, [], [])
84 if fd == p.stdout.fileno():
85 read = p.stdout.readline()
86 sys.stdout.write(read)
89 if fd == p.stderr.fileno():
90 read = p.stderr.readline()
91 sys.stderr.write(read)
100 return p.returncode, "".join(stdout), "".join(stderr)
103 def runTests(args, exe=None):
104 args = __configureTests(args, exe)
106 appliPath = os.getenv("ABSOLUTE_APPLI_PATH")
108 raise SalomeContextException("Unable to find application path. Please check that the variable ABSOLUTE_APPLI_PATH is set.")
110 testPath = os.path.join(appliPath, __testSubDir)
112 command = ["ctest"] + args
113 res, out, err = __runTest(command, testPath)