# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1532696029 -7200
#      Fri Jul 27 14:53:49 2018 +0200
# Node ID dd1acf7816df8e6fbc740837cbae96b891096798
# Parent  0d04981581e8b44e91a714266ea395851320b999
Fix unbundle test to use a temporary repository instead of the cache one

diff --git a/benchmarks/basic_commands.py b/benchmarks/basic_commands.py
--- a/benchmarks/basic_commands.py
+++ b/benchmarks/basic_commands.py
@@ -284,10 +284,27 @@
     def setup(self, repo_name, strip):
         super(UnbundleTimeSuite, self).setup(repo_name, "local", strip, None)
 
+        tmpdir = os.path.join(REPOS_DIR, '.tmp')
+        try:
+            os.makedirs(tmpdir)
+        except OSError as exc:
+            if exc.errno != errno.EEXIST:
+                raise
+
+        self.tmp_clone_path = os.path.join(tmpdir, 'clone-{}'.format(
+            os.path.basename(self.clone_path)))
+        # XXX: This should be deleted at the end but teardown, like setup, is
+        # called for each repeat...
+        self.check_output('rsync', '-aH', '--delete', '{}/'.format(self.clone_path),
+                          self.tmp_clone_path)
+        # Wait for everything to be written on disk to avoid Disk IO wait to
+        # impact performances metrics
+        self.check_output('sync')
+
         self.hg("bundle", "--base", "not(%s)" % strip, "/tmp/bundle.bundle")
 
     def time_debugunbundle(self, *args, **kwargs):
-        self.run(self.clone_path, 'unbundle', "/tmp/bundle.bundle",
+        self.run(self.tmp_clone_path, 'unbundle', "/tmp/bundle.bundle",
                  expected_return_code=0)