3 # runtests.py - wrapper script for running SCons tests
5 # This script mainly exists to set PYTHONPATH to the right list of
6 # directories to test the SCons modules.
8 # By default, it directly uses the modules in the local tree:
9 # ./src/ (source files we ship) and ./etc/ (other modules we don't)
11 # When "-b aegis" is specified, it assumes it's in a directory
12 # in which an Aegis build (aeb) has been performed, and sets
13 # PYTHONPATH so that it *only* references the modules that have
14 # unpacked from the built packages, to test whether the packages
19 # -a Run all tests; does a virtual 'find' for
20 # all SCons tests under the current directory.
22 # -b system Assume you're in the specified built system.
23 # 'aegis' is the only one currently defined.
25 # -d Debug. Runs the script under the Python
26 # debugger (pdb.py) so you don't have to
27 # muck with PYTHONPATH yourself.
29 # -q Quiet. By default, runtest.py prints the
30 # command line it will execute before
31 # executing it. This suppresses that print.
33 # -v Version. Specifies the version number to
34 # be used for Aegis interaction.
51 opts, tests = getopt.getopt(sys.argv[1:], "ab:dqv:",
52 ['all','build=','debug','quiet','version='])
55 if o == '-a' or o == '--all': all = 1
56 elif o == '-b' or o == '--build': build = a
57 elif o == '-d' or o == '--debug': debug = os.path.join(
60 "python" + sys.version[0:3],
62 elif o == '-q' or o == '--quiet': printcmd = 0
63 elif o == '-v' or o == '--version': version = a
68 map(os.path.abspath, tests)
70 def find_Test_py(arg, dirname, names):
72 n = filter(lambda n: n[-8:] == "Tests.py", names)
73 n = map(lambda x,d=dirname: os.path.join(d, x), n)
75 os.path.walk('src', find_Test_py, 0)
77 def find_py(arg, dirname, names):
79 n = filter(lambda n: n[-3:] == ".py", names)
80 n = map(lambda x,d=dirname: os.path.join(d, x), n)
82 os.path.walk('test', find_py, 0)
86 version = os.popen("aesub '$version'").read()[:-1]
88 match = re.compile(r'^[CD]0*')
90 def aegis_to_version(aever):
91 arr = string.split(aever, '.')
92 end = max(len(arr) - 1, 2)
93 arr = map(lambda e: match.sub('', e), arr[:end])
98 arr[1:] = map(rep, arr[1:])
99 return string.join(arr, '.')
101 version = aegis_to_version(version)
103 scons_dir = os.path.join(cwd, 'build', 'test', 'bin')
105 os.environ['PYTHONPATH'] = os.path.join(cwd,
109 'python' + sys.version[0:3],
114 scons_dir = os.path.join(cwd, 'src', 'script')
116 os.environ['PYTHONPATH'] = string.join([os.path.join(cwd, 'src', 'engine'),
117 os.path.join(cwd, 'etc')],
125 if os.path.isabs(path):
128 abs = os.path.join(cwd, path)
129 cmd = string.join(["python", debug, abs], " ")