-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathallTests.py
75 lines (66 loc) · 2.35 KB
/
allTests.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
#!/usr/bin/env python3
#Copyright (C) 2006-2012 by Benedict Paten ([email protected])
#
#Released under the MIT license, see LICENSE.txt
import unittest
import time
import bioioTest
import cigarsTest
from sonLib import treeTest
try:
import networkx as NX
networkx_installed = True
from sonLib import nxtreeTest
from sonLib import nxnewickTest
except ImportError:
networkx_installed = False
from sonLib.bioio import system
from sonLib.bioio import parseSuiteTestOptions
from sonLib.bioio import getLogLevelString
from subprocess import check_call, Popen
def needsProgram(program):
"""Decorator: Run this test only if "program" is available."""
def wrap(fn):
try:
check_call([program, "--version"])
except:
return unittest.skip(program + ' command is missing')(fn)
else:
return fn
return wrap
def needsPackage(package):
"""Decorator: Run this test only if "pkg-config --exists package" says OK!"""
def wrap(fn):
try:
check_call(["pkg-config", "--exists", package])
except:
return unittest.skip(package + ' pkg-config package is missing')(fn)
else:
return fn
return wrap
class TestCase(unittest.TestCase):
def testSonLibCTests(self):
"""Run most of the sonLib CuTests, fail if any of them fail."""
system("sonLibTests %s" % getLogLevelString())
def allSuites():
bioioSuite = unittest.makeSuite(bioioTest.TestCase, 'test')
cigarsSuite = unittest.makeSuite(cigarsTest.TestCase, 'test')
treeSuite = unittest.makeSuite(treeTest.TestCase, 'test')
cuTestsSuite = unittest.makeSuite(TestCase, 'test')
if not networkx_installed:
allTests = unittest.TestSuite((bioioSuite, cigarsSuite, treeSuite, cuTestsSuite))
else:
nxtreeSuite = unittest.makeSuite(nxtreeTest.TestCase, 'test')
nxnewickSuite = unittest.makeSuite(nxnewickTest.TestCase, 'test')
allTests = unittest.TestSuite((bioioSuite, cigarsSuite, treeSuite, cuTestsSuite,
nxtreeSuite, nxnewickSuite))
return allTests
def main():
parseSuiteTestOptions()
suite = allSuites()
runner = unittest.TextTestRunner(verbosity=2)
i = runner.run(suite)
return len(i.failures) + len(i.errors)
if __name__ == '__main__':
import sys
sys.exit(main())