root/runtests.py

Revision 156:a95bc663bfa0, 2.0 KB (checked in by Roger Gammans <rgammans@…>, 2 months ago)

Fix error packfile error handling

  • Property exe set to *
Line 
1#!/usr/bin/python
2
3# First cut of a routine to run our unittests for the
4# MysteryMachine Project
5
6
7#                       runtests.sh - Copyright Roger Gammans
8#
9#
10#    This program is free software; you can redistribute it and/or modify
11#    it under the terms of the GNU General Public License as published by
12#    the Free Software Foundation; either version 2 of the License, or
13#    (at your option) any later version.
14#
15#    This program is distributed in the hope that it will be useful,
16#    but WITHOUT ANY WARRANTY; without even the implied warranty of
17#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18#    GNU General Public License for more details.
19#
20#    You should have received a copy of the GNU General Public License along
21#    with this program; if not, write to the Free Software Foundation, Inc.,
22#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23#
24import os
25import imp
26import sys
27import re
28
29PYTHONS  =( 'python2.5', 'python2.6', 'python2.6 -3')
30UNITTEST ='/usr/lib/python2.6/unittest.py'
31TESTSDIR ='tests'
32
33STRIP   = re.compile('\.py$')
34
35sys.path.insert(0,"./%s" % TESTSDIR )
36
37path=os.getenv("PYTHONPATH")
38if path == None:
39        path = "."
40else:
41        #FIXME: Needs to be ';' under windows
42        path = ".:" + path
43
44os.putenv("PYTHONPATH",path)
45
46def NoTests():
47        return( )
48
49#Allow the ability to run tests under a single python.
50if len(sys.argv) > 1:
51    DEFPYTHONS=PYTHONS
52    PYTHONS = []
53   
54    for arg in sys.argv[1:]:
55        print arg
56        PYTHONS += [ 'python%s' % arg ]
57
58for python in (PYTHONS):
59        sys.stderr.write( "Testing under %s:\n" % python )
60        #TODO: should this inner loop go inside tests/__init__.py ?
61        for module in os.listdir('tests/'):
62                #Turn filenmae into module name
63                testname , replaced =re.subn(STRIP,"",module)
64                # SKip invalid module names
65                if not replaced: continue
66                #run tests.
67                sys.stderr.write("Running %s (%s)" % (module,python) )
68                os.system("%s %s/%s" % ( python,  TESTSDIR, module))
69
70sys.stderr.write("\n")
71sys.stdout.write("\n")
Note: See TracBrowser for help on using the browser.