summaryrefslogtreecommitdiff
path: root/runtest.py
blob: 9e51d765d8a0dcaae2fc7ba44102bb78a2f5c745 (plain)
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
#!/usr/bin/env python

import getopt
import os
import os.path
import re
import string
import sys

build = None
debug = ''
version = None

opts, tests = getopt.getopt(sys.argv[1:], "b:dv:",
			    ['build=','debug','version='])

for o, a in opts:
    if o == '-b' or o == '-build': build = a
    elif o == '-d' or o == '--debug': debug = "/usr/lib/python1.5/pdb.py"
    elif o == '-v' or o == '--version': version = a

cwd = os.getcwd()

map(os.path.abspath, tests)

if build == 'aegis':
    if not version:
	version = os.popen("aesub '$version'").read()[:-1]

    match = re.compile(r'^[CD]0*')

    def aegis_to_version(aever):
	arr = string.split(aever, '.')
	end = max(len(arr) - 1, 2)
	arr = map(lambda e: match.sub('', e), arr[:end])
	def rep(e):
	    if len(e) == 1:
		e = '0' + e
	    return e
	arr[1:] = map(rep, arr[1:])
	return string.join(arr, '.')

    version = aegis_to_version(version)

    build_test = os.path.join(cwd, "build", "test")
    scons_dir = os.path.join(build_test, "scons-" + version)

    os.environ['PYTHONPATH'] = string.join([scons_dir,
					    build_test],
					   os.pathsep)

else:

    scons_dir = os.path.join(cwd, 'src')

    os.environ['PYTHONPATH'] = string.join([os.path.join(cwd, 'src'),
					    os.path.join(cwd, 'etc')],
					   os.pathsep)

os.chdir(scons_dir)

fail = []

for path in tests:
    if os.path.isabs(path):
	abs = path
    else:
	abs = os.path.join(cwd, path)
    cmd = string.join(["python", debug, abs], " ")
    if os.system(cmd):
	fail.append(path)

sys.exit(len(fail))