author Gregory Szorc <>
Mon, 30 Jun 2014 18:42:45 -0700
changeset 358878 2b4ece5493e8200d80095d51af2d0363534d4d7a
parent 358852 27a1f27cb0acf1a234ed1d3b2599c879f9d9dba9
child 358889 fbb4bd1952831fa6fa882c879e6a035fe3ff7c8e
permissions -rwxr-xr-x
reviewboard: script for creating test environment; rbmozui Creating test environments was scriptable, so make a script to do it. The impetus for this was installing the rbmozui ReviewBoard extension, which required ` develop` mode to not introduce a Node.js dependency.

#!/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 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', '')
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('.'):

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

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

            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()