File: testall.py

package info (click to toggle)
zeroinstall-injector 0.34-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,048 kB
  • ctags: 1,236
  • sloc: python: 10,189; xml: 167; makefile: 34; sh: 16
file content (50 lines) | stat: -rwxr-xr-x 1,061 bytes parent folder | download
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
#!/usr/bin/env python2.4
import unittest, os, sys

# Catch silly mistakes...
os.environ['HOME'] = '/home/idontexist'

try:
	import coverage
	coverage.erase()
	coverage.start()
except ImportError:
	coverage = None

my_dir = os.path.dirname(sys.argv[0])
if not my_dir:
	my_dir=os.getcwd()

sys.argv.append('-v')

suite_names = [f[:-3] for f in os.listdir(my_dir)
		if f.startswith('test') and f.endswith('.py')]
suite_names.remove('testall')
suite_names.sort()

alltests = unittest.TestSuite()

for name in suite_names:
	m = __import__(name, globals(), locals(), [])
	alltests.addTest(m.suite)

a = unittest.TextTestRunner(verbosity=2).run(alltests)

if coverage:
	coverage.stop()
else:
	print "Coverage module not found. Skipping coverage report."

print "\nResult", a
if not a.wasSuccessful():
	sys.exit(1)

if coverage:
	all_sources = []
	def incl(d):
		for x in os.listdir(d):
			if x.endswith('.py'):
				all_sources.append(os.path.join(d, x))
	incl('../zeroinstall/injector')
	incl('../zeroinstall/zerostore')
	coverage.report(all_sources + ['../0launch'])