tests/run-tests.py
author Vadim Gelfer <vadim.gelfer@gmail.com>
Thu, 27 Apr 2006 22:01:28 -0700
changeset 2145 5bb3cb9e5d13
parent 2144 d3bddedfdbd0
child 2146 eb1ed410aa34
permissions -rwxr-xr-x
make indentation of coverage code in run-tests.py nicer.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     1
#!/usr/bin/env python
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     2
#
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     3
# run-tests.py - Run a set of tests on Mercurial
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     4
#
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     5
# Copyright 2006 Matt Mackall <mpm@selenic.com>
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     6
#
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     7
# This software may be used and distributed according to the terms
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     8
# of the GNU General Public License, incorporated herein by reference.
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
     9
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    10
import os, sys, shutil, re
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    11
import tempfile
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    12
import difflib
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    13
import popen2
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    14
from optparse import OptionParser
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    15
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    16
required_tools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"]
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    17
2144
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    18
parser = OptionParser("%prog [options] [tests]")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    19
parser.add_option("-v", "--verbose", action="store_true",
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    20
    help="output verbose messages")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    21
parser.add_option("-c", "--cover", action="store_true",
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    22
    help="print a test coverage report")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    23
parser.add_option("-s", "--cover_stdlib", action="store_true",
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    24
    help="print a test coverage report inc. standard libraries")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    25
parser.add_option("-C", "--annotate", action="store_true",
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    26
    help="output files annotated with coverage")
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    27
(options, args) = parser.parse_args()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    28
verbose = options.verbose
2144
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    29
coverage = options.cover or options.cover_stdlib or options.annotate
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    30
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    31
def vlog(*msg):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    32
    if verbose:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    33
        for m in msg:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    34
            print m,
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    35
        print
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    36
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    37
def show_diff(expected, output):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    38
    for line in difflib.unified_diff(expected, output,
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    39
            "Expected output", "Test output", lineterm=''):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    40
        print line
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    41
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    42
def find_program(program):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    43
    """Search PATH for a executable program"""
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    44
    for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    45
        name = os.path.join(p, program)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    46
        if os.access(name, os.X_OK):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    47
            return name
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    48
    return None
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    49
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    50
def check_required_tools():
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    51
    # Before we go any further, check for pre-requisite tools
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    52
    # stuff from coreutils (cat, rm, etc) are not tested
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    53
    for p in required_tools:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    54
        if os.name == 'nt':
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    55
            p += '.exe'
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    56
        found = find_program(p)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    57
        if found:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    58
            vlog("# Found prerequisite", p, "at", found)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    59
        else:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    60
            print "WARNING: Did not find prerequisite tool: "+p
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    61
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    62
def cleanup_exit():
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    63
    if verbose:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    64
        print "# Cleaning up HGTMP", HGTMP
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    65
    shutil.rmtree(HGTMP, True)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    66
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    67
def install_hg():
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    68
    vlog("# Performing temporary installation of HG")
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    69
    installerrs = os.path.join("tests", "install.err")
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    70
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    71
    os.chdir("..") # Get back to hg root
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    72
    cmd = '%s setup.py install --home="%s" --install-lib="%s" >%s 2>&1' % \
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    73
        (sys.executable, INST, PYTHONDIR, installerrs)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    74
    vlog("# Running", cmd)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    75
    if os.system(cmd) == 0:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    76
        if not verbose:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    77
            os.remove(installerrs)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    78
    else:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    79
        f = open(installerrs)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    80
        for line in f:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    81
            print line,
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    82
        f.close()
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    83
        sys.exit(1)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    84
    os.chdir(TESTDIR)
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    85
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    86
    os.environ["PATH"] = "%s%s%s" % (BINDIR, os.pathsep, os.environ["PATH"])
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
    87
    os.environ["PYTHONPATH"] = PYTHONDIR
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
    88
2144
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    89
    if coverage:
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    90
        vlog("# Installing coverage wrapper")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    91
        os.environ['COVERAGE_FILE'] = COVERAGE_FILE
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    92
        if os.path.exists(COVERAGE_FILE):
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    93
            os.unlink(COVERAGE_FILE)
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    94
        # Create a wrapper script to invoke hg via coverage.py
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    95
        os.rename(os.path.join(BINDIR, "hg"), os.path.join(BINDIR, "_hg.py")) 
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    96
        f = open(os.path.join(BINDIR, 'hg'), 'w')
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    97
        f.write('#!' + sys.executable + '\n')
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    98
        f.write('import sys, os; os.execv(sys.executable, [sys.executable, '+ \
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
    99
            '"%s", "-x", "%s"] + sys.argv[1:])\n' % (
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   100
            os.path.join(TESTDIR, 'coverage.py'),
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   101
            os.path.join(BINDIR, '_hg.py')))
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   102
        f.close()
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   103
        os.chmod(os.path.join(BINDIR, 'hg'), 0700)
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   104
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   105
def output_coverage():
2145
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   106
    vlog("# Producing coverage report")
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   107
    omit = [BINDIR, TESTDIR, PYTHONDIR]
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   108
    if not options.cover_stdlib:
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   109
        # Exclude as system paths (ignoring empty strings seen on win)
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   110
        omit += [x for x in sys.path if x != '']  
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   111
    omit = ','.join(omit)
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   112
    os.chdir(PYTHONDIR)
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   113
    cmd = '"%s" "%s" -r "--omit=%s"' % (
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   114
        sys.executable, os.path.join(TESTDIR, 'coverage.py'), omit)
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   115
    vlog("# Running: "+cmd)
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   116
    os.system(cmd)
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   117
    if options.annotate:
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   118
        adir = os.path.join(TESTDIR, 'annotated')
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   119
        if not os.path.isdir(adir):
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   120
            os.mkdir(adir)
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   121
        cmd = '"%s" "%s" -a "--directory=%s" "--omit=%s"' % (
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   122
            sys.executable, os.path.join(TESTDIR, 'coverage.py'),
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   123
            adir, omit)
2144
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   124
        vlog("# Running: "+cmd)
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   125
        os.system(cmd)
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   126
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   127
def run(cmd, split_lines=True):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   128
    """Run command in a sub-process, capturing the output (stdout and stderr).
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   129
    Return the exist code, and output."""
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   130
    # TODO: Use subprocess.Popen if we're running on Python 2.4
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   131
    if os.name == 'nt':
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   132
        tochild, fromchild = os.popen4(cmd)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   133
        tochild.close()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   134
        output = fromchild.read()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   135
        ret = fromchild.close()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   136
        if ret == None:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   137
            ret = 0
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   138
    else:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   139
        proc = popen2.Popen4(cmd)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   140
        proc.tochild.close()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   141
        output = proc.fromchild.read()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   142
        ret = proc.wait()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   143
    if split_lines:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   144
        output = output.splitlines()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   145
    return ret, output
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   146
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   147
def run_one(test):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   148
    vlog("# Test", test)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   149
    if not verbose:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   150
        sys.stdout.write('.')
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   151
        sys.stdout.flush()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   152
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   153
    err = os.path.join(TESTDIR, test+".err")
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   154
    ref = os.path.join(TESTDIR, test+".out")
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   155
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   156
    if os.path.exists(err):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   157
        os.remove(err)       # Remove any previous output files
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   158
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   159
    # Make a tmp subdirectory to work in
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   160
    tmpd = os.path.join(HGTMP, test)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   161
    os.mkdir(tmpd)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   162
    os.chdir(tmpd)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   163
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   164
    if test.endswith(".py"):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   165
        cmd = '%s "%s"' % (sys.executable, os.path.join(TESTDIR, test))
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   166
    else:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   167
        cmd = '"%s"' % (os.path.join(TESTDIR, test))
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   168
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   169
    # To reliably get the error code from batch files on WinXP,
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   170
    # the "cmd /c call" prefix is needed. Grrr
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   171
    if os.name == 'nt' and test.endswith(".bat"):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   172
        cmd = 'cmd /c call "%s"' % (os.path.join(TESTDIR, test))
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   173
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   174
    vlog("# Running", cmd)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   175
    ret, out = run(cmd)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   176
    vlog("# Ret was:", ret)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   177
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   178
    if ret == 0:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   179
        # If reference output file exists, check test output against it
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   180
        if os.path.exists(ref):
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   181
            f = open(ref, "r")
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   182
            ref_out = f.read().splitlines()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   183
            f.close()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   184
            if out != ref_out:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   185
                ret = 1
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   186
                print "\nERROR: %s output changed" % (test)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   187
                show_diff(ref_out, out)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   188
    else:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   189
        print "\nERROR: %s failed with error code %d" % (test, ret)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   190
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   191
    if ret != 0: # Save errors to a file for diagnosis
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   192
        f = open(err, "w")
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   193
        for line in out:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   194
            f.write(line)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   195
            f.write("\n")
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   196
        f.close()
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   197
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   198
    os.chdir(TESTDIR)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   199
    shutil.rmtree(tmpd, True)
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   200
    return ret == 0
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   201
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   202
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   203
os.umask(022)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   204
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   205
check_required_tools()
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   206
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   207
# Reset some environment variables to well-known values so that
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   208
# the tests produce repeatable output.
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   209
os.environ['LANG'] = os.environ['LC_ALL'] = 'C'
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   210
os.environ['TZ'] = 'GMT'
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   211
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   212
os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   213
os.environ["HGMERGE"]  = sys.executable + ' -c "import sys; sys.exit(0)"'
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   214
os.environ["HGUSER"]   = "test"
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   215
os.environ["HGRCPATH"] = ""
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   216
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   217
TESTDIR = os.environ["TESTDIR"] = os.getcwd()
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   218
HGTMP   = os.environ["HGTMP"]   = tempfile.mkdtemp("", "hgtests.")
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   219
vlog("# Using TESTDIR", TESTDIR)
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   220
vlog("# Using HGTMP", HGTMP)
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   221
2144
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   222
INST = os.path.join(HGTMP, "install")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   223
BINDIR = os.path.join(INST, "bin")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   224
PYTHONDIR = os.path.join(INST, "lib", "python")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   225
COVERAGE_FILE = os.path.join(TESTDIR, ".coverage")
d3bddedfdbd0 Add code coverage to the python version of run-tests (inc. annotation)
Stephen Darnell <stephen@darnell.plus.com>
parents: 2133
diff changeset
   226
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   227
try:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   228
    install_hg()
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   229
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   230
    tests = 0
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   231
    failed = 0
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   232
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   233
    if len(args) == 0:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   234
        args = os.listdir(".")
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   235
    for test in args:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   236
        if test.startswith("test-"):
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   237
            if '~' in test or re.search(r'\.(out|err)$', test):
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   238
                continue
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   239
            if not run_one(test):
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   240
                failed += 1
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   241
            tests += 1
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   242
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   243
    print "\n# Ran %d tests, %d failed." % (tests, failed)
2145
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   244
    if coverage:
5bb3cb9e5d13 make indentation of coverage code in run-tests.py nicer.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2144
diff changeset
   245
        output_coverage()
2133
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   246
finally:
4334be196f8d Tidyups for run-tests.py inc. try/finally cleanup and allow tests to be specified on command line
Stephen Darnell <stephen@darnell.plus.com>
parents: 2110
diff changeset
   247
    cleanup_exit()
2110
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   248
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   249
if failed:
25a8d116ab6a Add a pure python version of run-tests.
Stephen Darnell <stephen@darnell.plus.com>
parents:
diff changeset
   250
    sys.exit(1)