run-mercurial-tests.py
author Gregory Szorc <gps@mozilla.com>
Tue, 24 Jun 2014 00:10:19 -0700
changeset 358852 27a1f27cb0acf1a234ed1d3b2599c879f9d9dba9
parent 358819 9fd459bc4e6eba5846e48563108e707b858a572c
child 358889 fbb4bd1952831fa6fa882c879e6a035fe3ff7c8e
permissions -rwxr-xr-x
reviewboard: integrate Review Board server into tests We now launch a local Review Board service instance when running the Review Board tests. Along the way, the logic for mapping commits to reviews was rewritten to make it behave slightly better. The tests now need rework to download results from Review Board to ensure that the interaction actually does what we want it to do. There is a test failure in test-obsolescence.t, presumably due to a bug in commit<->review reconciling. The daemon process running the Review Board server also appears to get orphaned after the tests finish. These issues will be addressed later.

#!/usr/bin/env python

# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

# This file is used to run all Mercurial-related tests in this repository.

import imp
import os
import sys

# Mercurial's run-tests.py isn't meant to be loaded as a module. We do it
# anyway.
HERE = os.path.dirname(os.path.abspath(__file__))
RUNTESTS = os.path.join(HERE, 'pylib', 'mercurial-support', 'run-tests.py')
EXTDIR = os.path.join(HERE, 'hgext')

sys.path.insert(0, os.path.join(HERE, 'pylib', 'mercurial-support'))
runtestsmod = imp.load_source('runtests', RUNTESTS)


def find_test_files():
    """Find all test files in this repository."""
    for d in os.listdir(EXTDIR):
        if d.startswith('.'):
            continue

        test_dir = os.path.join(EXTDIR, d, 'tests')
        if not os.path.isdir(test_dir):
            continue

        for f in os.listdir(test_dir):
            if f.startswith('.'):
                continue

            if f.startswith('test-') and f.endswith(('.py', '.t')):
                yield os.path.join(test_dir, f)


if __name__ == '__main__':
    if not hasattr(sys, 'real_prefix'):
        raise Exception('You are not running inside the virtualenv. Please '
                'create one and `pip install -r test-requirements.txt`')

    hg = os.path.join(os.path.dirname(sys.executable), 'hg')
    sys.argv.extend(['--with-hg', hg])

    runner = runtestsmod.TestRunner()
    sys.argv.extend(find_test_files())
    sys.exit(runner.run(sys.argv[1:]))