summaryrefslogtreecommitdiff
path: root/test/other_tools/git_operations/git_repo_remote.test.cpp
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-02-23 18:51:51 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2024-03-08 14:16:45 +0100
commit2ebf355989eb92ac9967eceee0af14d39477afe0 (patch)
treedb993f8df39eb05b625b2c4590f1e5696b2e7b04 /test/other_tools/git_operations/git_repo_remote.test.cpp
parentc512ae174920ada425e2b33d0fea24891d6305bd (diff)
downloadjustbuild-2ebf355989eb92ac9967eceee0af14d39477afe0.tar.gz
just-mr: Fix shell out execution
... by avoiding reusing temp dirs for execute. While we are at it, also refactor LocalFetchViaTmpRepo() to create its own empty temp dirs, that cannot be reused by the caller.
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.cpp63
1 files changed, 13 insertions, 50 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 03df8553..0330e9be 100644
--- a/test/other_tools/git_operations/git_repo_remote.test.cpp
+++ b/test/other_tools/git_operations/git_repo_remote.test.cpp
@@ -240,17 +240,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
CHECK_FALSE(
*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
- // create tmp dir to use for fetch
- auto tmp_path_fetch_all = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(tmp_path_fetch_all));
// fetch all with base refspecs
- REQUIRE(repo_fetch_all->FetchViaTmpRepo(tmp_path_fetch_all,
- *repo_path,
- std::nullopt,
- {},
- "git",
- {},
- logger));
+ REQUIRE(repo_fetch_all->FetchViaTmpRepo(
+ *repo_path, std::nullopt, {}, "git", {}, logger));
// check commit is there after fetch
CHECK(*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
@@ -267,19 +259,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
CHECK_FALSE(
*repo_fetch_wRefspec->CheckCommitExists(kRootCommit, logger));
- // create tmp dir to use for fetch
- auto tmp_path_fetch_wRefspec = TestUtils::GetRepoPath();
- REQUIRE(
- FileSystemManager::CreateDirectory(tmp_path_fetch_wRefspec));
// fetch all
- REQUIRE(
- repo_fetch_wRefspec->FetchViaTmpRepo(tmp_path_fetch_wRefspec,
- *repo_path,
- "master",
- {},
- "git",
- {},
- logger));
+ REQUIRE(repo_fetch_wRefspec->FetchViaTmpRepo(
+ *repo_path, "master", {}, "git", {}, logger));
// check commit is there after fetch
CHECK(*repo_fetch_wRefspec->CheckCommitExists(kRootCommit, logger));
@@ -292,12 +274,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
GitRepoRemote::InitAndOpen(path_commit_upd, /*is_bare=*/true);
REQUIRE(repo_commit_upd);
- // create tmp dir to use for commits update
- auto tmp_path_commit_upd = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(tmp_path_commit_upd));
// do remote ls
auto fetched_commit = repo_commit_upd->UpdateCommitViaTmpRepo(
- tmp_path_commit_upd, *repo_path, "master", {}, "git", {}, logger);
+ *repo_path, "master", {}, "git", {}, logger);
REQUIRE(fetched_commit);
CHECK(*fetched_commit == kRootCommit);
@@ -356,14 +335,9 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
// something
} break;
case 1: {
- // create tmp dir to use for fetch
- auto tmp_path_fetch_all = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(
- tmp_path_fetch_all));
// fetch with base refspecs
CHECK(
- target_repo->FetchViaTmpRepo(tmp_path_fetch_all,
- *remote_repo_path,
+ target_repo->FetchViaTmpRepo(*remote_repo_path,
std::nullopt,
{},
"git",
@@ -371,30 +345,19 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
logger));
} break;
case 2: {
- // create tmp dir to use for fetch
- auto tmp_path_fetch_wRefspec =
- TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(
- tmp_path_fetch_wRefspec));
// fetch specific branch
- CHECK(target_repo->FetchViaTmpRepo(
- tmp_path_fetch_wRefspec,
- *remote_repo_path,
- "master",
- {},
- "git",
- {},
- logger));
+ CHECK(
+ target_repo->FetchViaTmpRepo(*remote_repo_path,
+ "master",
+ {},
+ "git",
+ {},
+ logger));
} break;
case 3: {
- // create tmp dir to use for commits update
- auto tmp_path_commit_upd = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(
- tmp_path_commit_upd));
// do remote ls
auto fetched_commit =
target_repo->UpdateCommitViaTmpRepo(
- tmp_path_commit_upd,
*remote_repo_path,
"master",
{},