From 2ebf355989eb92ac9967eceee0af14d39477afe0 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 23 Feb 2024 18:51:51 +0100 Subject: 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. --- .../git_operations/git_repo_remote.test.cpp | 63 +++++----------------- 1 file changed, 13 insertions(+), 50 deletions(-) (limited to 'test/other_tools/git_operations/git_repo_remote.test.cpp') 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", {}, -- cgit v1.2.3