Skip to content
Snippets Groups Projects
Commit 5f3205ac0df2 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

Change compatible_with decorator to not_compatible_with

This decorator will be used to mark versions that do not work most of the time.
So instead passing `compatible_with("not(revset)")` and a negative filter function,
we can just specify the revset wherein the bench should not run and optionally
further filter on test kwargs.
parent 598d2a3fe4f8
No related branches found
No related tags found
No related merge requests found
import os
import os.path
from .utils import BaseTestSuite, params_as_kwargs, REPO_DETAILS, compatible_with
from .utils import BaseTestSuite, params_as_kwargs, REPO_DETAILS
class PerfTestSuite(BaseTestSuite):
......@@ -5,8 +5,7 @@
class PerfTestSuite(BaseTestSuite):
#@compatible_with("4.8::")
def track_status(self, *args, **kwargs):
return self.perfext("perfstatus")
......
......@@ -226,8 +226,8 @@
return wrapper
def compatible_with(revset):
"""Specifies the revset wherein the command is expected to work.
def not_compatible_with(revset, filter_fn=None):
"""Specifies the revset wherein the command is NOT expected to work.
Skips the benchmark if the command is not expected to work.
The current version is obtained from the environment.
......@@ -236,12 +236,5 @@
def decorator(f):
@functools.wraps(f)
def wrapper(self, *args, **kwargs):
if not f.__name__.startswith('track'):
# TODO implement solution for other prefixes than `track`
raise NotImplementedError(
"This decorator is not compatible with "
"any prefixes other than `track`."
)
current_version = os.environ.get('ASV_COMMIT')
......@@ -246,10 +239,12 @@
current_version = os.environ.get('ASV_COMMIT')
if self.should_skip_benchmark(compatibility_revset=revset,
current_version=current_version):
if self.should_skip_benchmark(incompatibility_revset=revset,
current_version=current_version,
filter_fn=filter_fn,
test_kwargs=kwargs):
message = "{} is not expected to work for hash {}"
print(
message.format(f.__name__, current_version),
file=sys.stderr
)
......@@ -250,10 +245,10 @@
message = "{} is not expected to work for hash {}"
print(
message.format(f.__name__, current_version),
file=sys.stderr
)
return float('nan')
raise NotImplementedError()
return f(self, *args, **kwargs)
return wrapper
......@@ -295,7 +290,7 @@
# define the cache dir for simplicity
self._cache_dir = os.getcwd()
def should_skip_benchmark(self, compatibility_revset, current_version):
"""Determines whether the benchmark should be run given a
revset and the current mercurial version.
def should_skip_benchmark(self, incompatibility_revset, current_version, filter_fn, test_kwargs):
"""Determines whether the benchmark should be run given an exclusion
revset, the current mercurial version and an optional filter function.
......@@ -301,3 +296,5 @@
If no current version is set, returns `False`
The filter function can be used for deciding more precisely (most likely based
on test_kwargs) if the benchmark should be skipped. It must return a boolean, `True` if
it should indeed be skipped, `False` otherwise.
"""
......@@ -303,3 +300,4 @@
"""
should_skip = False
in_revset = True
in_filter = False
......@@ -305,3 +303,3 @@
if compatibility_revset is not None and current_version:
if incompatibility_revset is not None and current_version:
tmpl = "{} & {}"
......@@ -307,5 +305,5 @@
tmpl = "{} & {}"
full_revset = tmpl.format(compatibility_revset, current_version)
full_revset = tmpl.format(incompatibility_revset, current_version)
match_pattern = 'ASV_REVSET_MATCH'
# TODO use `hg test` when it's stable
......@@ -324,8 +322,8 @@
output = self.check_output(*command, env=self.environ)
except subprocess.CalledProcessError as exc:
if exc.returncode == 255:
should_skip = True
in_revset = False
else:
raise
else:
if not match_pattern in output:
......@@ -328,6 +326,6 @@
else:
raise
else:
if not match_pattern in output:
should_skip = True
in_revset = False
......@@ -333,5 +331,9 @@
return should_skip
if filter_fn and filter_fn(test_kwargs, current_version):
in_filter = True
return in_revset and in_filter
@staticmethod
def get_skip():
......
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