#!/usr/bin/env python import re import sys import optparse import subprocess from unipath import FSPath as Path # http://cheeseshop.python.org/pypi/Unipath PYTHONS = ["2.3", "2.4", "2.5"] DBS = ["postgres", "mysql", "sqlite"] p = optparse.OptionParser() p.add_option("-p", "--python", action="append") p.add_option("-d", "--db", action="append") p.add_option("-v", "--verbose", action="store_true") p.set_defaults(python=[], db=[], verbose=False) options, args = p.parse_args() if not options.python: options.python = PYTHONS if not options.db: options.db = DBS sys.path.append(Path(__file__).parent) for py in options.python: for db in options.db: if options.verbose: print "#"*80 print "Runing tests using Python %s / %s:" % (py, db) pipe = subprocess.Popen( ["python%s" % py, "runtests.py", "--settings=testsettings.%s" % db] + args, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, cwd = Path(__file__).parent.child("django.trunk").child("tests"), ) out, err = pipe.communicate() if options.verbose: print out else: outlines = out.split("\n") failures = [l for l in outlines if re.match("^(FAIL|ERROR): ", l)] lastline = out.split("\n")[-2] print "Python %s / %s: %s" % (py, db, lastline) if failures: for f in failures: print "\t%s" % f print