1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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
|