summaryrefslogtreecommitdiff
path: root/test/buildtool/file_system
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-07-02 13:21:14 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-07-05 13:32:39 +0200
commitd202e8f6051df5eb89d0f2eb1b9ac7109d204f56 (patch)
tree562d90c0a5396a259d11c4288162403489a6e4fd /test/buildtool/file_system
parent5140befaa10f65145fe041b416b7764127efc379 (diff)
downloadjustbuild-d202e8f6051df5eb89d0f2eb1b9ac7109d204f56.tar.gz
Remove HermeticLocalTestFixture
...and create StorageConfig and Storage in place if needed.
Diffstat (limited to 'test/buildtool/file_system')
-rw-r--r--test/buildtool/file_system/TARGETS3
-rw-r--r--test/buildtool/file_system/git_repo.test.cpp18
-rw-r--r--test/buildtool/file_system/object_cas.test.cpp9
3 files changed, 20 insertions, 10 deletions
diff --git a/test/buildtool/file_system/TARGETS b/test/buildtool/file_system/TARGETS
index c202fa32..333e2b7e 100644
--- a/test/buildtool/file_system/TARGETS
+++ b/test/buildtool/file_system/TARGETS
@@ -27,7 +27,7 @@
, ["@", "src", "src/buildtool/common", "bazel_types"]
, ["@", "src", "src/buildtool/common", "common"]
, ["@", "src", "src/buildtool/storage", "config"]
- , ["utils", "local_hermeticity"]
+ , ["utils", "test_storage_config"]
]
, "stage": ["test", "buildtool", "file_system"]
}
@@ -127,6 +127,7 @@
, ["@", "src", "src/utils/cpp", "hex_string"]
, ["@", "src", "src/buildtool/storage", "config"]
, ["utils", "shell_quoting"]
+ , ["utils", "test_storage_config"]
]
, "stage": ["test", "buildtool", "file_system"]
}
diff --git a/test/buildtool/file_system/git_repo.test.cpp b/test/buildtool/file_system/git_repo.test.cpp
index 94801dfe..969f2072 100644
--- a/test/buildtool/file_system/git_repo.test.cpp
+++ b/test/buildtool/file_system/git_repo.test.cpp
@@ -32,6 +32,7 @@
#include "src/buildtool/storage/config.hpp"
#include "src/utils/cpp/atomic.hpp"
#include "src/utils/cpp/hex_string.hpp"
+#include "test/utils/hermeticity/test_storage_config.hpp"
#include "test/utils/shell_quoting.hpp"
namespace {
@@ -277,6 +278,8 @@ TEST_CASE("Single-threaded real repository local operations", "[git_repo]") {
// warning
TEST_CASE("Single-threaded fake repository operations -- batch 1",
"[git_repo]") {
+ auto const storage_config = TestStorageConfig::Create();
+
auto repo_path = TestUtils::CreateTestRepoWithCheckout();
REQUIRE(repo_path);
auto cas = GitCAS::Open(*repo_path);
@@ -419,7 +422,7 @@ TEST_CASE("Single-threaded fake repository operations -- batch 1",
// fetch all with base refspecs
REQUIRE(repo_fetch_all->LocalFetchViaTmpRepo(
- StorageConfig::Instance(), *repo_path, std::nullopt, logger));
+ storage_config.Get(), *repo_path, std::nullopt, logger));
// check commit is there after fetch
CHECK(*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
@@ -438,7 +441,7 @@ TEST_CASE("Single-threaded fake repository operations -- batch 1",
// fetch branch
REQUIRE(repo_fetch_branch->LocalFetchViaTmpRepo(
- StorageConfig::Instance(), *repo_path, "master", logger));
+ storage_config.Get(), *repo_path, "master", logger));
// check commit is there after fetch
CHECK(*repo_fetch_branch->CheckCommitExists(kRootCommit, logger));
@@ -580,6 +583,8 @@ TEST_CASE("Single-threaded fake repository operations -- batch 2",
}
TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") {
+ 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.
@@ -608,8 +613,11 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") {
constexpr int NUM_CASES = 10;
for (int id{}; id < kNumThreads; ++id) {
threads.emplace_back(
- [&remote_cas, &remote_repo_path, &logger, &starting_signal](
- int tid) {
+ [&storage_config,
+ &remote_cas,
+ &remote_repo_path,
+ &logger,
+ &starting_signal](int tid) {
starting_signal.wait(false);
// cases based on thread number
switch (tid % NUM_CASES) {
@@ -729,7 +737,7 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") {
REQUIRE(remote_repo->IsRepoFake());
// fetch all
REQUIRE(remote_repo->LocalFetchViaTmpRepo(
- StorageConfig::Instance(),
+ storage_config.Get(),
*remote_repo_path,
std::nullopt,
logger));
diff --git a/test/buildtool/file_system/object_cas.test.cpp b/test/buildtool/file_system/object_cas.test.cpp
index 2fc0a405..be9ba709 100644
--- a/test/buildtool/file_system/object_cas.test.cpp
+++ b/test/buildtool/file_system/object_cas.test.cpp
@@ -23,14 +23,15 @@
#include "src/buildtool/file_system/object_cas.hpp"
#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/storage/config.hpp"
-#include "test/utils/hermeticity/local.hpp"
+#include "test/utils/hermeticity/test_storage_config.hpp"
+
+TEST_CASE("ObjectCAS", "[file_system]") {
+ auto const storage_config = TestStorageConfig::Create();
+ auto gen_config = storage_config.Get().CreateGenerationConfig(0);
-TEST_CASE_METHOD(HermeticLocalTestFixture, "ObjectCAS", "[file_system]") {
std::string test_content{"test"};
auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content);
- auto gen_config = StorageConfig::Instance().CreateGenerationConfig(0);
-
SECTION("CAS for files") {
ObjectCAS<ObjectType::File> cas{gen_config.cas_f};
CHECK(not cas.BlobPath(test_digest));