File: test.py

package info (click to toggle)
bzrtools 2.6.0-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 740 kB
  • sloc: python: 4,299; sh: 13; makefile: 10
file content (33 lines) | stat: -rwxr-xr-x 927 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
USAGE = """Just run test.py.  Any supplied arguments are treated as PYTHONPATH
prefixes."""
import sys
import os.path
import unittest
import tempfile
import shutil
path_prefix = []
if len(sys.argv) > 1:
    if sys.argv[1] in ("-h", "--help", ""):
        print USAGE
        sys.exit(0)
    path_prefix = sys.argv[1:]
path_prefix.append(os.path.join(os.path.dirname(__file__), ".."))
sys.path = [os.path.realpath(p) for p in path_prefix] + sys.path
try:
    from bzrlib.plugins import bzrtools
except ImportError, e:
    if len(sys.argv) == 1 and "bzrlib" in str(e):
        print "You can specify the path to bzrlib as the first argument"
    raise
suite = bzrtools.test_suite()
runner = unittest.TextTestRunner(verbosity=0)
tempdir = tempfile.mkdtemp()

try:
    os.chdir(tempdir)
    result = runner.run(suite)
finally:
    shutil.rmtree(tempdir)

sys.exit({True: 0, False: 3}[result.wasSuccessful()])