299
by Aaron Bentley
Added stand-alone tester |
1 |
#!/usr/bin/env python2.4
|
2 |
USAGE = """Just run test.py. Any supplied arguments are treated as PYTHONPATH |
|
3 |
prefixes."""
|
|
4 |
import sys |
|
5 |
import os.path |
|
6 |
import unittest |
|
301
by Aaron Bentley
Avoided leaving junk all over the place when running standalone tests. |
7 |
import tempfile |
8 |
import shutil |
|
299
by Aaron Bentley
Added stand-alone tester |
9 |
path_prefix = [] |
10 |
if len(sys.argv) > 1: |
|
11 |
if sys.argv[1] in ("-h", "--help", ""): |
|
12 |
print USAGE |
|
13 |
sys.exit(0) |
|
14 |
path_prefix = sys.argv[1:] |
|
15 |
path_prefix.append(os.path.join(os.path.dirname(__file__), "..")) |
|
16 |
sys.path = [os.path.realpath(p) for p in path_prefix] + sys.path |
|
17 |
try: |
|
18 |
import bzrtools |
|
19 |
except ImportError, e: |
|
20 |
if len(sys.argv) == 1 and "bzrlib" in str(e): |
|
494
by Aaron Bentley
Fix speling |
21 |
print "You can specify the path to bzrlib as the first argument" |
299
by Aaron Bentley
Added stand-alone tester |
22 |
raise
|
23 |
suite = bzrtools.test_suite() |
|
24 |
runner = unittest.TextTestRunner(verbosity=0) |
|
301
by Aaron Bentley
Avoided leaving junk all over the place when running standalone tests. |
25 |
tempdir = tempfile.mkdtemp() |
26 |
||
27 |
try: |
|
28 |
os.chdir(tempdir) |
|
29 |
result = runner.run(suite) |
|
30 |
finally: |
|
31 |
shutil.rmtree(tempdir) |
|
32 |
||
299
by Aaron Bentley
Added stand-alone tester |
33 |
sys.exit({True: 0, False: 3}[result.wasSuccessful()]) |