2010-05-14 19:39:26 +04:00
|
|
|
import optparse
|
2008-10-08 07:13:14 +04:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
2010-05-14 22:26:06 +04:00
|
|
|
def tests():
|
|
|
|
import test_util
|
|
|
|
import test_binaryfiles
|
|
|
|
import test_diff
|
|
|
|
import test_externals
|
|
|
|
import test_fetch_branches
|
|
|
|
import test_fetch_command
|
|
|
|
import test_fetch_command_regexes
|
|
|
|
import test_fetch_exec
|
|
|
|
import test_fetch_mappings
|
|
|
|
import test_fetch_renames
|
|
|
|
import test_fetch_symlinks
|
|
|
|
import test_fetch_truncated
|
|
|
|
import test_pull
|
|
|
|
import test_push_command
|
|
|
|
import test_push_renames
|
|
|
|
import test_push_dirs
|
|
|
|
import test_push_eol
|
|
|
|
import test_rebuildmeta
|
|
|
|
import test_single_dir_clone
|
|
|
|
import test_svnwrap
|
|
|
|
import test_tags
|
|
|
|
import test_utility_commands
|
|
|
|
import test_urls
|
2008-10-08 07:13:14 +04:00
|
|
|
|
2010-05-14 22:26:06 +04:00
|
|
|
sys.path.append(os.path.dirname(__file__))
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), 'comprehensive'))
|
2009-06-15 21:26:20 +04:00
|
|
|
|
2010-05-14 22:26:06 +04:00
|
|
|
import test_stupid_pull
|
|
|
|
import test_verify
|
|
|
|
|
|
|
|
return locals()
|
2009-06-11 13:34:37 +04:00
|
|
|
|
|
|
|
def comprehensive(mod):
|
|
|
|
dir = os.path.basename(os.path.dirname(mod.__file__))
|
|
|
|
return dir == 'comprehensive'
|
|
|
|
|
2008-10-08 07:13:14 +04:00
|
|
|
if __name__ == '__main__':
|
2010-05-14 19:39:26 +04:00
|
|
|
description = ("This script runs the hgsubversion tests. If no tests are "
|
|
|
|
"specified, all known tests are implied.")
|
|
|
|
parser = optparse.OptionParser(usage="%prog [options] [TESTS ...]",
|
|
|
|
description=description)
|
|
|
|
parser.add_option("-A", "--all",
|
|
|
|
dest="comprehensive", action="store_true", default=False,
|
|
|
|
help="include slow, but comprehensive tests")
|
|
|
|
parser.add_option("-v", "--verbose",
|
|
|
|
dest="verbose", action="store_true", default=False,
|
|
|
|
help="enable verbose output")
|
2010-05-14 22:27:24 +04:00
|
|
|
parser.add_option("", "--no-demandimport",
|
|
|
|
dest="demandimport", action="store_false", default=True,
|
|
|
|
help="disable Mercurial demandimport loading")
|
2009-05-28 10:48:57 +04:00
|
|
|
|
2010-05-14 19:39:26 +04:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if options.verbose:
|
|
|
|
testargs = { 'descriptions': 3, 'verbosity': 2 }
|
|
|
|
else:
|
|
|
|
testargs = {'descriptions': 2}
|
2009-03-27 05:42:52 +03:00
|
|
|
|
2010-05-18 23:46:50 +04:00
|
|
|
# make sure our copy of hgsubversion gets imported
|
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
|
2010-05-14 22:27:24 +04:00
|
|
|
if options.demandimport:
|
|
|
|
from mercurial import demandimport
|
|
|
|
demandimport.enable()
|
|
|
|
|
2009-05-15 19:24:08 +04:00
|
|
|
# silence output when running outside nose
|
2010-07-05 00:41:42 +04:00
|
|
|
import tempfile
|
|
|
|
sys.stdout = tempfile.TemporaryFile()
|
2009-05-15 19:24:08 +04:00
|
|
|
|
2010-05-14 22:26:06 +04:00
|
|
|
all = tests()
|
2009-05-28 10:48:57 +04:00
|
|
|
del all['test_util']
|
|
|
|
|
|
|
|
args = [i.split('.py')[0].replace('-', '_') for i in args]
|
|
|
|
|
|
|
|
if not args:
|
2010-05-14 19:39:26 +04:00
|
|
|
check = lambda x: options.comprehensive or not comprehensive(x)
|
2009-06-11 13:34:37 +04:00
|
|
|
mods = [m for (n, m) in sorted(all.iteritems()) if check(m)]
|
|
|
|
suite = [m.suite() for m in mods]
|
2009-05-28 10:48:57 +04:00
|
|
|
else:
|
|
|
|
suite = []
|
|
|
|
for arg in args:
|
2010-05-14 19:39:26 +04:00
|
|
|
if arg == 'test_util':
|
|
|
|
continue
|
|
|
|
elif arg not in all:
|
2009-06-11 13:39:45 +04:00
|
|
|
print >> sys.stderr, 'test module %s not available' % arg
|
2009-05-28 10:48:57 +04:00
|
|
|
else:
|
|
|
|
suite.append(all[arg].suite())
|
|
|
|
|
2010-05-14 19:39:26 +04:00
|
|
|
runner = unittest.TextTestRunner(**testargs)
|
2010-03-02 02:45:00 +03:00
|
|
|
result = runner.run(unittest.TestSuite(suite))
|
|
|
|
if not result.wasSuccessful():
|
|
|
|
sys.exit(1)
|