# HG changeset patch # User Idan Kamara # Date 1318701784 -7200 # Node ID f4f636ecca3ee65d39fd2dd9621a738121b1187c # Parent a5dd7b5d0be11a52a5207f421db6e90751fe548e tests: add a nose plugin that allows specifying a custom hg to run tests diff -r a5dd7b5d0be1 -r f4f636ecca3e tests/with_hg.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/with_hg.py Sat Oct 15 20:03:04 2011 +0200 @@ -0,0 +1,33 @@ +import os +from nose.plugins import Plugin + +class WithHgPlugin(Plugin): + name = 'with-hg' + enabled = False + + def options(self, parser, env): + Plugin.options(self, parser, env) + parser.add_option('--with-hg', + action='store', + type='string', + metavar='HG', + dest='with_hg', + help='test using specified hg script.') + + def configure(self, options, conf): + Plugin.configure(self, options, conf) + if options.with_hg: + self.enabled = True + self.hgpath = os.path.realpath(options.with_hg) + + def begin(self): + import hglib + + p = hglib.util.popen([self.hgpath, 'version']) + p.communicate() + + if p.returncode: + raise ValueError("custom hg %r doesn't look like Mercurial" + % self.hgpath) + + hglib.HGPATH = self.hgpath