Skip to content
Snippets Groups Projects
Commit 49aa5eec authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Handle params "repo_type" and "revset" Mixin class

In following changesets we will add exchanges benchmarks not using "strip" or
"revset" params.

Moving this outside of the BaseExchangeTimeSuite allow to re-use this logic
without inheriting from it.
parent dbf6c2ca
No related branches found
No related tags found
No related merge requests found
...@@ -233,14 +233,7 @@ ...@@ -233,14 +233,7 @@
self.thread.join() self.thread.join()
class BaseExchangeTimeSuite(BaseTestSuite): class BaseExchangeMixin(object):
param_names = BaseTestSuite.param_names + [
'repo_type', 'strip', 'revset']
params = BaseTestSuite.params + [
['local', 'ssh', 'http'],
get_strip_variants(),
[None, 'tip']]
timeout = 1800
def _remote_path_cmd(self, path): def _remote_path_cmd(self, path):
if self.repo_type == 'local': if self.repo_type == 'local':
...@@ -265,6 +258,36 @@ ...@@ -265,6 +258,36 @@
else: else:
raise NotImplementedError raise NotImplementedError
def _setup_repo_type(self, repo_type):
self._hgserve = None
if repo_type == 'http' and self.get_asv_rev() in self.get_skip()['hgweb']:
raise NotImplementedError
self.repo_type = repo_type
if repo_type == 'http':
self._hgserve = HgWeb()
self.hgport = self._hgserve.start(self.hgpath, self.environ)
def _teardown_repo_type(self):
if self._hgserve is not None:
self._hgserve.stop()
self._hgserve = None
def _setup_revset(self, revset):
if revset is not None:
self.rev = self.hg('identify', '-i', '-r', revset).strip()
else:
self.rev = None
class BaseExchangeTimeSuite(BaseExchangeMixin, BaseTestSuite):
param_names = BaseTestSuite.param_names + [
'repo_type', 'strip', 'revset']
params = BaseTestSuite.params + [
['local', 'ssh', 'http'],
get_strip_variants(),
[None, 'tip']]
timeout = 1800
def run(self, local_repo, command, remote_repo, expected_return_code=None): def run(self, local_repo, command, remote_repo, expected_return_code=None):
if not isinstance(command, (list, tuple)): if not isinstance(command, (list, tuple)):
command = [command] command = [command]
...@@ -276,11 +299,14 @@ ...@@ -276,11 +299,14 @@
expected_return_code = 1 if self.strip == "same" else 0 expected_return_code = 1 if self.strip == "same" else 0
self.hg(*cmd, expected_return_code=expected_return_code) self.hg(*cmd, expected_return_code=expected_return_code)
def setup(self, repo_name, repo_type, strip, revset): def setup(self, *args):
super(BaseExchangeTimeSuite, self).setup(repo_name) args = list(args)
self._hgserve = None revset = args.pop(-1)
if repo_type == 'http' and self.get_asv_rev() in self.get_skip()['hgweb']: self.strip = args.pop(-1)
raise NotImplementedError repo_type = args.pop(-1)
super(BaseExchangeTimeSuite, self).setup(*args)
self._setup_repo_type(repo_type)
self._setup_revset(revset)
repo_suffix = urllib.quote_plus(strip) repo_suffix = urllib.quote_plus(strip)
self.clone_path = os.path.join(REPOS_DIR, '.cache', '{}-partial-{}'.format( self.clone_path = os.path.join(REPOS_DIR, '.cache', '{}-partial-{}'.format(
repo_name, repo_suffix)) repo_name, repo_suffix))
...@@ -284,14 +310,5 @@ ...@@ -284,14 +310,5 @@
repo_suffix = urllib.quote_plus(strip) repo_suffix = urllib.quote_plus(strip)
self.clone_path = os.path.join(REPOS_DIR, '.cache', '{}-partial-{}'.format( self.clone_path = os.path.join(REPOS_DIR, '.cache', '{}-partial-{}'.format(
repo_name, repo_suffix)) repo_name, repo_suffix))
if revset is not None:
self.rev = self.hg('identify', '-i', '-r', revset).strip()
else:
self.rev = None
self.strip = strip
self.repo_type = repo_type
if repo_type == 'http':
self._hgserve = HgWeb()
self.hgport = self._hgserve.start(self.hgpath, self.environ)
def teardown(self, *args, **kwargs): def teardown(self, *args, **kwargs):
...@@ -296,7 +313,6 @@ ...@@ -296,7 +313,6 @@
def teardown(self, *args, **kwargs): def teardown(self, *args, **kwargs):
if self._hgserve is not None: self._teardown_repo_type()
self._hgserve.stop()
class ExchangeTimeSuite(BaseExchangeTimeSuite): class ExchangeTimeSuite(BaseExchangeTimeSuite):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment