Only display selected dependencies in autocompile output
[0compile.git] / tests / runall.py
bloba14baea6363aa7455dd500d8a4b24d5c94baa387
1 #!/usr/bin/env python
2 import unittest, os, sys, tempfile, shutil, atexit
4 my_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
6 coverdir = tempfile.mkdtemp(prefix='0compile-coverage-')
7 atexit.register(shutil.rmtree, coverdir)
9 os.environ["COVERAGE_FILE"] = os.path.join(coverdir, 'coverage')
11 try:
12 import coverage
13 coverage.erase()
14 except ImportError:
15 coverage = None
16 print "Coverage module not found. Skipping coverage report."
18 sys.argv.append('-v')
20 suite_names = [f[:-3] for f in os.listdir(my_dir)
21 if f.startswith('test') and f.endswith('.py')]
22 suite_names.sort()
24 alltests = unittest.TestSuite()
26 for name in suite_names:
27 m = __import__(name, globals(), locals(), [])
28 alltests.addTest(m.suite)
30 a = unittest.TextTestRunner(verbosity=2).run(alltests)
32 print "\nResult", a
33 if not a.wasSuccessful():
34 sys.exit(1)
36 if coverage:
37 coverage.the_coverage.collect()
38 all_sources = []
39 def incl(d):
40 for x in os.listdir(d):
41 if x.endswith('.py'):
42 all_sources.append(os.path.join(d, x))
43 incl(os.path.join(my_dir, '..'))
44 coverage.report(all_sources)