# HG changeset patch # User Philippe Pepiot <phil@philpep.org> # Date 1516355181 -3600 # Fri Jan 19 10:46:21 2018 +0100 # Node ID d0c320751e22aba0f2685ad865c775b8da453167 # Parent 985612958032c4508d12f9c6aa80672ac5e9b0c1 Add variation of exchange benchmarks using the same repo state expect a return code of 1 for incoming, outgoing and push in this case. diff --git a/benchmarks/basic_commands.py b/benchmarks/basic_commands.py --- a/benchmarks/basic_commands.py +++ b/benchmarks/basic_commands.py @@ -141,7 +141,7 @@ class BaseExchangeTimeSuite(BaseTimeTestSuite): param_names = BaseTimeTestSuite.param_names + ['strip', 'revset'] - params = BaseTimeTestSuite.params + [['last(all(), 10)']] + [[None, 'default']] + params = BaseTimeTestSuite.params + [['same', 'last(all(), 10)']] + [[None, 'default']] def setup(self, repo_name, strip, revset): self.timer = timeit.default_timer @@ -163,13 +163,13 @@ cmd = [self.hgpath, '--cwd', self.clone_path, 'incoming', self.repo_path] if self.rev: cmd.extend(['-r', self.rev]) - self._single_execute(cmd) + self._single_execute(cmd, expected_return_code=1 if strip == "same" else 0) def time_outgoing(self, repo_name, strip, revset): cmd = [self.hgpath, '--cwd', self.repo_path, 'outgoing', self.clone_path] if self.rev: cmd.extend(['-r', self.rev]) - self._single_execute(cmd) + self._single_execute(cmd, expected_return_code=1 if strip == "same" else 0) class PushPullTimeSuite(BaseExchangeTimeSuite): @@ -196,7 +196,7 @@ self.tmp_clone_path] if self.rev: cmd.extend(['-r', self.rev]) - self._single_execute(cmd) + self._single_execute(cmd, expected_return_code=1 if strip == "same" else 0) # class CloneTrackSuite(BaseTrackTestSuite): diff --git a/benchmarks/utils.py b/benchmarks/utils.py --- a/benchmarks/utils.py +++ b/benchmarks/utils.py @@ -220,9 +220,13 @@ return cmd - def _single_execute(self, cmd): - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, - env=self.environ) + def _single_execute(self, cmd, expected_return_code=0): + try: + subprocess.check_output(cmd, stderr=subprocess.STDOUT, + env=self.environ) + except subprocess.CalledProcessError as exc: + if exc.returncode != expected_return_code: + raise class BaseNChangesetsTestSuite(BaseTimeTestSuite): diff --git a/prepare_repos.py b/prepare_repos.py --- a/prepare_repos.py +++ b/prepare_repos.py @@ -9,7 +9,7 @@ import yaml # changesets stripped in partial clones -PARTIAL_REVSET = ('last(all(), 10)',) +PARTIAL_REVSET = ("same", 'last(all(), 10)',) def read_configuration(config_path): @@ -33,13 +33,15 @@ partialdir = join(cachedir, 'partial-{}-{}'.format( repo_name, base64.b64encode(revset))) if not isdir(partialdir): - print("Cloning partial %s (%s stripped off %s) into %s (for exchange benchmarks)" % ( - repo_name, clonedir, revset, partialdir)) + print("Cloning %s (%s%s) into %s (for exchange benchmarks)" % ( + repo_name, clonedir, + " stripped of %s" % (revset,) if revset != "same" else "", partialdir)) subprocess.check_call(['hg', 'clone', '--noupdate', clonedir, partialdir]) - subprocess.check_call(['hg', '--cwd', partialdir, 'strip', '-r', - revset]) - subprocess.check_call(['hg', '--cwd', partialdir, 'debugupdatecache']) + if revset != "same": + subprocess.check_call(['hg', '--cwd', partialdir, 'strip', '-r', + revset]) + subprocess.check_call(['hg', '--cwd', partialdir, 'debugupdatecache']) config = read_configuration("config.yaml")