Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 42 lines (38 sloc) 1.546 kb
668a2eb @yakky Half-baked solution to run each testcase isolated from the others. It st...
yakky authored
1 #!/usr/bin/env python
2 from __future__ import with_statement
3 import pkgutil
4 import pyclbr
5 import subprocess
6 import argparse
7 import sys
8 import os.path
f3c6b07 @yakky Fixed runtests-isolated.py
yakky authored
9 #from iterools import ifilter
668a2eb @yakky Half-baked solution to run each testcase isolated from the others. It st...
yakky authored
10
f3c6b07 @yakky Fixed runtests-isolated.py
yakky authored
11 def main(argv, failfast=False, test_labels=None):
668a2eb @yakky Half-baked solution to run each testcase isolated from the others. It st...
yakky authored
12 testlist = []
f3c6b07 @yakky Fixed runtests-isolated.py
yakky authored
13 for module in [name for _, name, _ in pkgutil.iter_modules([os.path.join("cms","tests")])]:
14 clsmembers = pyclbr.readmodule("cms.tests.%s" % module)
15 for clsname,cls in clsmembers.items():
16 testlist.append(cls)
17
18 for cls in testlist:
19 for method, line in cls.methods.items():
20 if not method.startswith('test_'):
21 continue
22 test = '%s.%s' % (cls.name, method)
23 if not test_labels or filter(lambda x: test.find(x)>-1, test_labels):
24 print "Running ",test,
25 args = ['python', 'runtests.py'] + argv + [test]
2cdd3d1 @yakky Using test discovery to load tests. It doesn't work, though
yakky authored
26 p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr= subprocess.PIPE)
27 output, error = p.communicate()
28 if p.returncode > 0:
f3c6b07 @yakky Fixed runtests-isolated.py
yakky authored
29 print error
2cdd3d1 @yakky Using test discovery to load tests. It doesn't work, though
yakky authored
30 if failfast:
31 sys.exit(p.returncode)
f3c6b07 @yakky Fixed runtests-isolated.py
yakky authored
32 else:
33 print
668a2eb @yakky Half-baked solution to run each testcase isolated from the others. It st...
yakky authored
34
35 if __name__ == '__main__':
36 parser = argparse.ArgumentParser()
37 parser.add_argument('--failfast', action='store_true', default=False,
38 dest='failfast')
f3c6b07 @yakky Fixed runtests-isolated.py
yakky authored
39 parser.add_argument('test_labels', nargs='*')
668a2eb @yakky Half-baked solution to run each testcase isolated from the others. It st...
yakky authored
40 args = parser.parse_args()
f3c6b07 @yakky Fixed runtests-isolated.py
yakky authored
41 main(sys.argv[2:],failfast=args.failfast,test_labels=args.test_labels)
Something went wrong with that request. Please try again.