summaryrefslogtreecommitdiff
path: root/test/buildtool/file_system
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-05-23 11:43:07 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-04 14:34:44 +0200
commite5010e47df602404d332d9686c04fa12358e3644 (patch)
tree7a4e92afd9186f0206a726a3c45d8d0be9cd1cce /test/buildtool/file_system
parented25b0f77690abe1f04e4cdcb284b7e17208d169 (diff)
downloadjustbuild-e5010e47df602404d332d9686c04fa12358e3644.tar.gz
FileRoot: Give git-based roots access to storage config
Diffstat (limited to 'test/buildtool/file_system')
-rw-r--r--test/buildtool/file_system/TARGETS1
-rw-r--r--test/buildtool/file_system/file_root.test.cpp69
2 files changed, 51 insertions, 19 deletions
diff --git a/test/buildtool/file_system/TARGETS b/test/buildtool/file_system/TARGETS
index 5062ee29..7d760fc1 100644
--- a/test/buildtool/file_system/TARGETS
+++ b/test/buildtool/file_system/TARGETS
@@ -77,6 +77,7 @@
, ["", "catch-main"]
, ["utils", "shell_quoting"]
, ["utils", "test_hash_function_type"]
+ , ["utils", "test_storage_config"]
]
, "stage": ["test", "buildtool", "file_system"]
}
diff --git a/test/buildtool/file_system/file_root.test.cpp b/test/buildtool/file_system/file_root.test.cpp
index db0fdf11..46b52e79 100644
--- a/test/buildtool/file_system/file_root.test.cpp
+++ b/test/buildtool/file_system/file_root.test.cpp
@@ -32,6 +32,7 @@
#include "src/buildtool/file_system/object_type.hpp"
#include "src/utils/cpp/expected.hpp"
#include "test/utils/hermeticity/test_hash_function_type.hpp"
+#include "test/utils/hermeticity/test_storage_config.hpp"
#include "test/utils/shell_quoting.hpp"
namespace {
@@ -195,11 +196,14 @@ TEST_CASE("Creating file root", "[file_root]") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root = FileRoot::FromGit(*repo_path, kTreeSymId);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root =
+ FileRoot::FromGit(&storage_config.Get(), *repo_path, kTreeSymId);
REQUIRE(root);
CHECK(root->Exists("."));
- CHECK_FALSE(FileRoot::FromGit("does_not_exist", kTreeSymId));
+ CHECK_FALSE(FileRoot::FromGit(
+ &storage_config.Get(), "does_not_exist", kTreeSymId));
}
SECTION("local root ignore-special") {
@@ -216,13 +220,18 @@ TEST_CASE("Creating file root", "[file_root]") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root =
- FileRoot::FromGit(*repo_path, kTreeSymId, /*ignore_special=*/true);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root = FileRoot::FromGit(&storage_config.Get(),
+ *repo_path,
+ kTreeSymId,
+ /*ignore_special=*/true);
REQUIRE(root);
CHECK(root->Exists("."));
- CHECK_FALSE(FileRoot::FromGit(
- "does_not_exist", kTreeSymId, /*ignore_special=*/true));
+ CHECK_FALSE(FileRoot::FromGit(&storage_config.Get(),
+ "does_not_exist",
+ kTreeSymId,
+ /*ignore_special=*/true));
}
}
@@ -237,7 +246,9 @@ TEST_CASE("Reading files", "[file_root]") {
SECTION("git root") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root = FileRoot::FromGit(*repo_path, kTreeSymId);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root =
+ FileRoot::FromGit(&storage_config.Get(), *repo_path, kTreeSymId);
REQUIRE(root);
TestFileRootReadFilesAndSymlinks(*root);
@@ -254,8 +265,11 @@ TEST_CASE("Reading files", "[file_root]") {
SECTION("git root ignore-special") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root =
- FileRoot::FromGit(*repo_path, kTreeSymId, /*ignore_special=*/true);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root = FileRoot::FromGit(&storage_config.Get(),
+ *repo_path,
+ kTreeSymId,
+ /*ignore_special=*/true);
REQUIRE(root);
TestFileRootReadFilesOnly(*root);
@@ -273,7 +287,9 @@ TEST_CASE("Reading directories", "[file_root]") {
SECTION("git root") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root = FileRoot::FromGit(*repo_path, kTreeSymId);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root =
+ FileRoot::FromGit(&storage_config.Get(), *repo_path, kTreeSymId);
REQUIRE(root);
TestFileRootReadDirectory(*root, /*with_symlinks=*/true);
@@ -290,8 +306,11 @@ TEST_CASE("Reading directories", "[file_root]") {
SECTION("git root ignore-special") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root =
- FileRoot::FromGit(*repo_path, kTreeSymId, /*ignore_special=*/true);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root = FileRoot::FromGit(&storage_config.Get(),
+ *repo_path,
+ kTreeSymId,
+ /*ignore_special=*/true);
REQUIRE(root);
TestFileRootReadDirectory(*root, /*with_symlinks=*/false);
@@ -309,7 +328,9 @@ TEST_CASE("Reading blobs", "[file_root]") {
SECTION("git root") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root = FileRoot::FromGit(*repo_path, kTreeSymId);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root =
+ FileRoot::FromGit(&storage_config.Get(), *repo_path, kTreeSymId);
REQUIRE(root);
auto foo = root->ReadBlob(kFooIdGitSha1);
@@ -330,8 +351,11 @@ TEST_CASE("Reading blobs", "[file_root]") {
SECTION("git root ignore-special") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root =
- FileRoot::FromGit(*repo_path, kTreeSymId, /*ignore_special=*/true);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root = FileRoot::FromGit(&storage_config.Get(),
+ *repo_path,
+ kTreeSymId,
+ /*ignore_special=*/true);
REQUIRE(root);
auto foo = root->ReadBlob(kFooIdGitSha1);
@@ -353,7 +377,9 @@ TEST_CASE("Reading blob type", "[file_root]") {
SECTION("git root") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root = FileRoot::FromGit(*repo_path, kTreeSymId);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root =
+ FileRoot::FromGit(&storage_config.Get(), *repo_path, kTreeSymId);
REQUIRE(root);
TestFileRootReadBlobType(*root);
@@ -369,8 +395,11 @@ TEST_CASE("Reading blob type", "[file_root]") {
SECTION("git root ignore-special") {
auto repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto root =
- FileRoot::FromGit(*repo_path, kTreeSymId, /*ignore_special=*/true);
+ auto const storage_config = TestStorageConfig::Create();
+ auto root = FileRoot::FromGit(&storage_config.Get(),
+ *repo_path,
+ kTreeSymId,
+ /*ignore_special=*/true);
REQUIRE(root);
TestFileRootReadBlobType(*root);
@@ -417,7 +446,9 @@ static void CheckGitRoot(HashFunction::Type hash_type,
bool ignore_special) noexcept {
auto const repo_path = CreateTestRepoSymlinks(false);
REQUIRE(repo_path);
- auto const root = FileRoot::FromGit(*repo_path, kTreeSymId, ignore_special);
+ auto const storage_config = TestStorageConfig::Create();
+ auto const root = FileRoot::FromGit(
+ &storage_config.Get(), *repo_path, kTreeSymId, ignore_special);
REQUIRE(root);
auto const foo = root->ToArtifactDescription(hash_type, "baz/foo", "repo");