Skip to content
Snippets Groups Projects
Commit 6fc2663c authored by Boris Feld's avatar Boris Feld
Browse files

Fix setups and test methods prototype to cope with the new variants

As we know use kwargs in setup too, we need to change how we compute the
repo_name.
parent cde8f975
No related branches found
No related tags found
No related merge requests found
......@@ -301,13 +301,11 @@
expected_return_code = 1 if self.strip == "same" else 0
self.hg(*cmd, expected_return_code=expected_return_code)
def setup(self, repo_name, *args):
args = list(args)
revset = args.pop(-1)
self.strip = args.pop(-1)
repo_type = args.pop(-1)
super(BaseExchangeTimeSuite, self).setup(repo_name, *args)
@params_as_kwargs
def setup(self, repo, repo_type, strip, revset, **kwargs):
self.strip = strip
super(BaseExchangeTimeSuite, self).setup(repo, **kwargs)
self._setup_repo_type(repo_type)
self._setup_revset(revset)
repo_suffix = urllib.quote_plus(self.strip)
self.clone_path = os.path.join(REPOS_DIR, '.cache', '{}-partial-{}'.format(
......@@ -310,8 +308,8 @@
self._setup_repo_type(repo_type)
self._setup_revset(revset)
repo_suffix = urllib.quote_plus(self.strip)
self.clone_path = os.path.join(REPOS_DIR, '.cache', '{}-partial-{}'.format(
repo_name, repo_suffix))
repo, repo_suffix))
def teardown(self, *args, **kwargs):
self._teardown_repo_type()
......@@ -355,8 +353,9 @@
get_strip_variants()]
param_names = BaseTestSuite.param_names + ['strip']
def setup(self, repo_name, strip):
super(UnbundleTimeSuite, self).setup(repo_name, "local", strip, None)
@params_as_kwargs
def setup(self, repo, strip, **kwargs):
super(UnbundleTimeSuite, self).setup(repo, repo_type="local", strip=strip, revset=None, **kwargs)
tmpdir = os.path.join(REPOS_DIR, '.tmp')
try:
......
......@@ -37,6 +37,8 @@
with open(STRIP_VARIANTS_PATH) as f:
STRIP_VARIANTS = yaml.load(f.read())["partial-sets"]
FORMAT_VARIANT_PREFIX = "repo-format"
def get_repo_variants(repo_dir):
"""read all .benchrepo in given directory and computes ASV variants
......@@ -121,7 +123,7 @@
# Add a prefix to format-info keys
new_format_info = {}
for format_name, format_value in format_info.items():
new_format_name = "repo-format-{}".format(format_name)
new_format_name = "{}-{}".format(FORMAT_VARIANT_PREFIX, format_name)
new_format_info[new_format_name] = format_value
format_variants[new_format_name].add(format_value)
......@@ -262,7 +264,8 @@
params = BASE_PARAMS
param_names = BASE_PARAMS_NAMES
def setup(self, repo, *args, **kwargs):
@params_as_kwargs
def setup(self, repo, **kwargs):
venv = os.path.abspath(os.path.join(os.path.dirname(sys.executable), ".."))
self.project_dir = os.path.join(venv, 'project')
if os.path.isdir(self.project_dir):
......@@ -273,7 +276,7 @@
self.project_dir = os.path.join(BASEDIR, 'mercurial')
sys.path.insert(0, self.project_dir)
self.hgpath = os.path.join(os.path.join(self.project_dir, 'hg'))
self.repo_name = self.get_repo_name(repo, *args)
self.repo_name = self.get_repo_name(repo, **kwargs)
self.repo_path = os.path.join(REPOS_DIR, self.repo_name)
# Use a clean environ to run command
......@@ -329,6 +332,6 @@
with open(os.path.join(REPOS_DIR, 'skip.json'), 'r') as f:
return json.load(f)
def get_repo_name(self, *args):
def get_repo_name(self, repo, **kwargs):
# Old way
if BASE_PARAMS_LEN == 1:
......@@ -333,13 +336,18 @@
# Old way
if BASE_PARAMS_LEN == 1:
return args[0]
else:
# Rebuilt format data in order to compute the hash
repo_id = args[0]
format_data = dict(zip(self.param_names[1:BASE_PARAMS_LEN], args[1:BASE_PARAMS_LEN]))
repo_hash_key = (repo_id, tuple(sorted(format_data.items())))
repo_hash = REPO_HASH_MAP[repo_hash_key]
return "{0}-{1}".format(repo_id, repo_hash)
return repo
# Filter the format variants
variants = {}
for key, value in kwargs.items():
if not key.startswith(FORMAT_VARIANT_PREFIX):
continue
variants[key] = value
repo_hash_key = (repo, tuple(sorted(variants.items())))
repo_hash = REPO_HASH_MAP[repo_hash_key]
return "{0}-{1}".format(repo, repo_hash)
def get_asv_rev(self):
'''Return currently benchmarked mercurial revision'''
......
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