diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-02 15:12:44 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-05 13:32:39 +0200 |
commit | b1ce7ce328e322cafa2401af77a9334c61b72034 (patch) | |
tree | 4d6c5168c1c006b1ab735978afdec00b1832befb /test | |
parent | d202e8f6051df5eb89d0f2eb1b9ac7109d204f56 (diff) | |
download | justbuild-b1ce7ce328e322cafa2401af77a9334c61b72034.tar.gz |
Convert StorageConfig to a general class
Diffstat (limited to 'test')
-rw-r--r-- | test/buildtool/graph_traverser/graph_traverser_remote.test.cpp | 16 | ||||
-rw-r--r-- | test/buildtool/storage/large_object_cas.test.cpp | 4 | ||||
-rw-r--r-- | test/utils/hermeticity/test_storage_config.hpp | 13 |
3 files changed, 23 insertions, 10 deletions
diff --git a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp index d9de3b10..d1663c52 100644 --- a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp +++ b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp @@ -20,13 +20,21 @@ [[nodiscard]] static auto CreateConfig() -> StorageConfig { auto cache_dir = FileSystemManager::GetCurrentDirectory() / "cache"; - auto storage_config = StorageConfig::Instance(); if (not FileSystemManager::RemoveDirectory(cache_dir, true) or - not FileSystemManager::CreateDirectoryExclusive(cache_dir) or - not storage_config.SetBuildRoot(cache_dir)) { + not FileSystemManager::CreateDirectoryExclusive(cache_dir)) { + Logger::Log(LogLevel::Error, + "failed to create a test-local cache dir {}", + cache_dir.string()); std::exit(EXIT_FAILURE); } - return storage_config; + + StorageConfig::Builder builder; + auto config = builder.SetBuildRoot(cache_dir).Build(); + if (not config) { + Logger::Log(LogLevel::Error, config.error()); + std::exit(EXIT_FAILURE); + } + return *std::move(config); } TEST_CASE("Remote: Output created and contents are correct", diff --git a/test/buildtool/storage/large_object_cas.test.cpp b/test/buildtool/storage/large_object_cas.test.cpp index 8daf1eaf..09935a40 100644 --- a/test/buildtool/storage/large_object_cas.test.cpp +++ b/test/buildtool/storage/large_object_cas.test.cpp @@ -195,7 +195,7 @@ static void TestLarge(StorageConfig const& storage_config, CHECK(pack_3->size() == pack_1->size()); // Check there are no spliced results in all generations: - for (std::size_t i = 0; i < storage_config.NumGenerations(); ++i) { + for (std::size_t i = 0; i < storage_config.num_generations; ++i) { auto const storage = ::Generation::Create(&storage_config); auto generation_path = kIsTree ? storage.CAS().TreePath(digest) @@ -605,7 +605,7 @@ TEST_CASE("LargeObjectCAS: uplink nested large objects", "[storage]") { REQUIRE(split_nested_blob_2); // Check there are no spliced results in old generations: - for (std::size_t i = 1; i < storage_config.Get().NumGenerations(); ++i) { + for (std::size_t i = 1; i < storage_config.Get().num_generations; ++i) { auto const storage = ::Generation::Create(&storage_config.Get(), /*generation=*/i); auto const& generation_cas = storage.CAS(); diff --git a/test/utils/hermeticity/test_storage_config.hpp b/test/utils/hermeticity/test_storage_config.hpp index e2906ad1..0323f77e 100644 --- a/test/utils/hermeticity/test_storage_config.hpp +++ b/test/utils/hermeticity/test_storage_config.hpp @@ -41,18 +41,23 @@ class TestStorageConfig final { std::filesystem::path{std::string{std::getenv("TEST_TMPDIR")}} / ".test_build_root"; - StorageConfig config = StorageConfig::Instance(); auto temp_dir = TmpDir::Create(test_tempdir); - if (temp_dir == nullptr or - not config.SetBuildRoot(temp_dir->GetPath())) { + if (temp_dir == nullptr) { Logger::Log(LogLevel::Error, "failed to create a test-local cache dir"); std::exit(EXIT_FAILURE); } + + StorageConfig::Builder builder; + auto config = builder.SetBuildRoot(temp_dir->GetPath()).Build(); + if (not config) { + Logger::Log(LogLevel::Error, config.error()); + std::exit(EXIT_FAILURE); + } Logger::Log(LogLevel::Debug, "created test-local cache dir {}", temp_dir->GetPath().string()); - return TestStorageConfig{std::move(temp_dir), std::move(config)}; + return TestStorageConfig{std::move(temp_dir), *std::move(config)}; } [[nodiscard]] auto Get() const noexcept -> StorageConfig const& { |