summaryrefslogtreecommitdiff
path: root/test/other_tools/git_operations/git_repo_remote.test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/other_tools/git_operations/git_repo_remote.test.cpp')
-rw-r--r--test/other_tools/git_operations/git_repo_remote.test.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/test/other_tools/git_operations/git_repo_remote.test.cpp b/test/other_tools/git_operations/git_repo_remote.test.cpp
index 89bfad23..0844205d 100644
--- a/test/other_tools/git_operations/git_repo_remote.test.cpp
+++ b/test/other_tools/git_operations/git_repo_remote.test.cpp
@@ -29,6 +29,7 @@
#include "src/buildtool/storage/config.hpp"
#include "src/other_tools/git_operations/git_repo_remote.hpp"
#include "src/utils/cpp/atomic.hpp"
+#include "test/utils/hermeticity/test_storage_config.hpp"
#include "test/utils/shell_quoting.hpp"
namespace {
@@ -222,6 +223,8 @@ TEST_CASE("Single-threaded real repository remote operations",
}
TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
+ auto const storage_config = TestStorageConfig::Create();
+
auto repo_path = TestUtils::CreateTestRepoWithCheckout();
REQUIRE(repo_path);
auto cas = GitCAS::Open(*repo_path);
@@ -251,7 +254,7 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
// fetch all with base refspecs
- REQUIRE(repo_fetch_all->FetchViaTmpRepo(StorageConfig::Instance(),
+ REQUIRE(repo_fetch_all->FetchViaTmpRepo(storage_config.Get(),
*repo_path,
std::nullopt,
{},
@@ -275,14 +278,13 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
*repo_fetch_wRefspec->CheckCommitExists(kRootCommit, logger));
// fetch all
- REQUIRE(
- repo_fetch_wRefspec->FetchViaTmpRepo(StorageConfig::Instance(),
- *repo_path,
- "master",
- {},
- "git",
- {},
- logger));
+ REQUIRE(repo_fetch_wRefspec->FetchViaTmpRepo(storage_config.Get(),
+ *repo_path,
+ "master",
+ {},
+ "git",
+ {},
+ logger));
// check commit is there after fetch
CHECK(*repo_fetch_wRefspec->CheckCommitExists(kRootCommit, logger));
@@ -296,14 +298,8 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
REQUIRE(repo_commit_upd);
// do remote ls
- auto fetched_commit =
- repo_commit_upd->UpdateCommitViaTmpRepo(StorageConfig::Instance(),
- *repo_path,
- "master",
- {},
- "git",
- {},
- logger);
+ auto fetched_commit = repo_commit_upd->UpdateCommitViaTmpRepo(
+ storage_config.Get(), *repo_path, "master", {}, "git", {}, logger);
REQUIRE(fetched_commit);
CHECK(*fetched_commit == kRootCommit);
@@ -311,6 +307,8 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
}
TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
+ auto const storage_config = TestStorageConfig::Create();
+
/*
Test all fake repository operations while being done in parallel.
They are supposed to be thread-safe, so no conflicts should exist.
@@ -349,8 +347,11 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
constexpr int NUM_CASES = 4;
for (int id{}; id < kNumThreads; ++id) {
threads.emplace_back(
- [&target_repo, &remote_repo_path, &logger, &starting_signal](
- int tid) {
+ [&storage_config,
+ &target_repo,
+ &remote_repo_path,
+ &logger,
+ &starting_signal](int tid) {
starting_signal.wait(false);
// cases based on thread number
switch (tid % NUM_CASES) {
@@ -364,7 +365,7 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
case 1: {
// fetch with base refspecs
CHECK(target_repo->FetchViaTmpRepo(
- StorageConfig::Instance(),
+ storage_config.Get(),
*remote_repo_path,
std::nullopt,
{},
@@ -375,7 +376,7 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
case 2: {
// fetch specific branch
CHECK(target_repo->FetchViaTmpRepo(
- StorageConfig::Instance(),
+ storage_config.Get(),
*remote_repo_path,
"master",
{},
@@ -387,7 +388,7 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
// do remote ls
auto fetched_commit =
target_repo->UpdateCommitViaTmpRepo(
- StorageConfig::Instance(),
+ storage_config.Get(),
*remote_repo_path,
"master",
{},