forked from idiap/asrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
allTestSuite.py
executable file
·88 lines (69 loc) · 3.02 KB
/
allTestSuite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of asrt.
# asrt is free software: you can redistribute it and/or modify
# it under the terms of the BSD 3-Clause License as published by
# the Open Source Initiative.
# asrt is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# BSD 3-Clause License for more details.
# You should have received a copy of the BSD 3-Clause License
# along with asrt. If not, see <http://opensource.org/licenses/>.
__author__ = "Alexandre Nanchen"
__version__ = "Revision: 1.0"
__date__ = "Date: 2015/04"
__copyright__ = "Copyright (c) 2015 Idiap Research Institute"
__license__ = "BSD 3-Clause"
import os, sys
import unittest
scriptsDir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(scriptsDir + "/../")
import asrt.common.unit_test.CommonTestSuite as CommonTestSuite
import asrt.common.french.unit_test.FrenchTestSuite as FrenchTestSuite
import asrt.common.german.unit_test.GermanTestSuite as GermanTestSuite
import asrt.common.english.unit_test.EnglishTestSuite as EnglishTestSuite
import asrt.common.formula.unit_test.FormulaTestSuite as FormulaTestSuite
from asrt.common.MyFile import MyFile
from asrt.config.AsrtConfig import TEMPDIRUNITTEST
usage = """
Run specific unit tests or all.
Available unit tests are: %s
"""
def getUsage():
strTests = "%s, %s, %s, %s, %s" % \
(CommonTestSuite.getSuite(), FormulaTestSuite.getSuite(),
FrenchTestSuite.getSuite(), GermanTestSuite.getSuite(),
EnglishTestSuite.getSuite())
return usage % strTests
def asrtTestSuite(unitTestList = None):
"""Build test suite for all test sui tes in the script folder
"""
#Return test suite objects
commonTestSuite = CommonTestSuite.getCommonTestSuite(unitTestList)
frenchTestSuite = FrenchTestSuite.getFrenchTestSuite(unitTestList)
germanTestSuite = GermanTestSuite.getGermanTestSuite(unitTestList)
englishTestSuite = EnglishTestSuite.getEnglishTestSuite(unitTestList)
formulaTestSuite = FormulaTestSuite.getFormulaTestSuite(unitTestList)
allTestSuite = []
if commonTestSuite is not None:
allTestSuite.extend(commonTestSuite)
if formulaTestSuite is not None:
allTestSuite.extend(formulaTestSuite)
if frenchTestSuite is not None:
allTestSuite.extend(frenchTestSuite)
if germanTestSuite is not None:
allTestSuite.extend(germanTestSuite)
if englishTestSuite is not None:
allTestSuite.extend(englishTestSuite)
allTests = unittest.TestSuite(allTestSuite)
return allTests
if __name__ == "__main__":
if len(sys.argv) < 2:
print getUsage()
print " usage: %s 'unit test name 1 or all' 'unit test name 2' " % sys.argv[0]
print ""
sys.exit(0)
MyFile.checkDirExists(TEMPDIRUNITTEST)
runner = unittest.TextTestRunner(verbosity = 2)
runner.run(asrtTestSuite(sys.argv[1:]))