comparison tests/with_hg.py @ 75:f4f636ecca3e

tests: add a nose plugin that allows specifying a custom hg to run tests
author Idan Kamara <idankk86@gmail.com>
date Sat, 15 Oct 2011 20:03:04 +0200
parents
children
comparison
equal deleted inserted replaced
74:a5dd7b5d0be1 75:f4f636ecca3e
1 import os
2 from nose.plugins import Plugin
3
4 class WithHgPlugin(Plugin):
5 name = 'with-hg'
6 enabled = False
7
8 def options(self, parser, env):
9 Plugin.options(self, parser, env)
10 parser.add_option('--with-hg',
11 action='store',
12 type='string',
13 metavar='HG',
14 dest='with_hg',
15 help='test using specified hg script.')
16
17 def configure(self, options, conf):
18 Plugin.configure(self, options, conf)
19 if options.with_hg:
20 self.enabled = True
21 self.hgpath = os.path.realpath(options.with_hg)
22
23 def begin(self):
24 import hglib
25
26 p = hglib.util.popen([self.hgpath, 'version'])
27 p.communicate()
28
29 if p.returncode:
30 raise ValueError("custom hg %r doesn't look like Mercurial"
31 % self.hgpath)
32
33 hglib.HGPATH = self.hgpath