1
|
1 |
#!/usr/bin/env python
|
|
2 |
# Copyright (C) 2005, Giovanni Bajo
|
|
3 |
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
|
|
4 |
#
|
|
5 |
# This program is free software; you can redistribute it and/or
|
|
6 |
# modify it under the terms of the GNU General Public License
|
|
7 |
# as published by the Free Software Foundation; either version 2
|
|
8 |
# of the License, or (at your option) any later version.
|
|
9 |
#
|
|
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program; if not, write to the Free Software
|
|
17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
18 |
|
|
19 |
# This program will execute any file with name test*<digit>.py. If your test
|
|
20 |
# need an aditional dependency name it test*<digit><letter>.py to be ignored
|
|
21 |
# by this program but be recognizable by any one as a dependency of that
|
|
22 |
# particual test.
|
|
23 |
|
|
24 |
import os, sys, glob, string
|
|
25 |
import shutil
|
|
26 |
try:
|
|
27 |
here=os.path.dirname(__file__)
|
|
28 |
except NameError:
|
|
29 |
here=os.path.dirname(sys.argv[0])
|
|
30 |
PYTHON = sys.executable
|
|
31 |
if sys.platform[:3] == 'win':
|
|
32 |
if string.find(PYTHON, ' ') > -1:
|
|
33 |
PYTHON='"%s"' % PYTHON
|
|
34 |
|
|
35 |
def clean():
|
|
36 |
distdirs = glob.glob(os.path.join(here, 'disttest*'))
|
|
37 |
for dir in distdirs:
|
|
38 |
try:
|
|
39 |
shutil.rmtree(dir)
|
|
40 |
except OSError, e:
|
|
41 |
print e
|
|
42 |
builddirs = glob.glob(os.path.join(here, 'buildtest*'))
|
|
43 |
for dir in builddirs:
|
|
44 |
try:
|
|
45 |
shutil.rmtree(dir)
|
|
46 |
except OSError, e:
|
|
47 |
print e
|
|
48 |
wfiles = glob.glob(os.path.join(here, 'warn*.txt'))
|
|
49 |
for file in wfiles:
|
|
50 |
try:
|
|
51 |
os.remove(file)
|
|
52 |
except OSError, e:
|
|
53 |
print e
|
|
54 |
|
|
55 |
def runtests():
|
|
56 |
global here
|
|
57 |
sources = glob.glob(os.path.join(here, 'test*[0-9].py'))
|
|
58 |
path = os.environ["PATH"]
|
|
59 |
for src in sources:
|
|
60 |
print
|
|
61 |
print "################## EXECUTING TEST %s ################################" % src
|
|
62 |
print
|
|
63 |
test = os.path.splitext(os.path.basename(src))[0]
|
|
64 |
os.system('%s ../Build.py %s' % (PYTHON, test+".spec"))
|
|
65 |
# Run the test in a clean environment to make sure they're really self-contained
|
|
66 |
del os.environ["PATH"]
|
|
67 |
os.system('dist%s%s%s' % (test, os.sep, test))
|
|
68 |
os.environ["PATH"] = path
|
|
69 |
print "################## FINISHING TEST %s ################################" % src
|
|
70 |
|
|
71 |
if __name__ == '__main__':
|
|
72 |
if len(sys.argv) == 1:
|
|
73 |
clean()
|
|
74 |
runtests()
|
|
75 |
if '--clean' in sys.argv:
|
|
76 |
clean()
|
|
77 |
if '--run' in sys.argv:
|
|
78 |
runtests()
|
|
79 |
raw_input("Press any key to exit")
|