Fixed updating of last-check-attempt
[zeroinstall/solver.git] / tests / testall.py
blobb4d027fd0bb9d36e9b7cf13e66c00c1f28627ed5
1 #!/usr/bin/env python
3 from __future__ import print_function
5 import unittest, os, sys
7 # Catch silly mistakes...
8 os.environ['HOME'] = '/home/idontexist'
10 try:
11 import coverage
12 coverage.erase()
13 coverage.start()
14 except ImportError:
15 coverage = None
17 my_dir = os.path.dirname(sys.argv[0])
18 if not my_dir:
19 my_dir=os.getcwd()
21 sys.argv.append('-v')
23 suite_names = [f[:-3] for f in os.listdir(my_dir)
24 if f.startswith('test') and f.endswith('.py')]
25 suite_names.remove('testall')
26 suite_names.sort()
28 alltests = unittest.TestSuite()
30 for name in suite_names:
31 m = __import__(name, globals(), locals(), [])
32 test = unittest.defaultTestLoader.loadTestsFromModule(m)
33 alltests.addTest(test)
35 a = unittest.TextTestRunner(verbosity=2).run(alltests)
37 if coverage:
38 coverage.stop()
39 else:
40 print("Coverage module not found. Skipping coverage report.")
42 print("\nResult", a)
43 if not a.wasSuccessful():
44 sys.exit(1)
46 if coverage:
47 all_sources = []
48 def incl(d):
49 for x in os.listdir(d):
50 if x.endswith('.py'):
51 all_sources.append(os.path.join(d, x))
52 incl('../zeroinstall')
53 incl('../zeroinstall/support')
54 incl('../zeroinstall/cmd')
55 incl('../zeroinstall/injector')
56 incl('../zeroinstall/zerostore')
57 coverage.report(all_sources + ['../0launch'])