# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1685494826 -3600
#      Wed May 31 02:00:26 2023 +0100
# Node ID 56c5cd5a0bb256309de4ff2b372652d35d821190
# Parent  2d4b8d9a4f4b1ebf40604943f52eeb459d828027
setup-base-dir: use a cache of target `repositories` during tests

This make the test speed something we can live with again.

diff --git a/.repos_cache/README b/.repos_cache/README
new file mode 100644
--- /dev/null
+++ b/.repos_cache/README
@@ -0,0 +1,1 @@
+A directory used to avoid cloning the same repository again and again during tests
diff --git a/bin/setup-base-dir b/bin/setup-base-dir
--- a/bin/setup-base-dir
+++ b/bin/setup-base-dir
@@ -109,6 +109,15 @@
         source,
         dest,
     ]
+    if "TESTTMP" in environ:
+        command.extend([
+            "--config",
+            "extensions.share=",
+            "--config",
+            "share.poolnaming=remote",
+            "--config",
+            f"share.pool={POULPE_DIR}/.repos_caches",
+        ])
     subprocess.run(command, check=True)