summaryrefslogtreecommitdiff
path: root/test/buildtool/file_system
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-12 11:52:55 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-13 14:41:00 +0200
commit0be15127f1ecbd4010c657e908e62ed5f4b737dc (patch)
tree1e2897dc587018f4903e3e0c0783ffee0a158ac4 /test/buildtool/file_system
parent74498f0633d9039bbb7971efa33d4242cd724812 (diff)
downloadjustbuild-0be15127f1ecbd4010c657e908e62ed5f4b737dc.tar.gz
Pass HashFunction::Type to SourceTargetMap
...that is to be used by FileRoot::ToArtifactDescription.
Diffstat (limited to 'test/buildtool/file_system')
-rw-r--r--test/buildtool/file_system/file_root.test.cpp77
1 files changed, 41 insertions, 36 deletions
diff --git a/test/buildtool/file_system/file_root.test.cpp b/test/buildtool/file_system/file_root.test.cpp
index 1e7b9e7b..1a27dd1b 100644
--- a/test/buildtool/file_system/file_root.test.cpp
+++ b/test/buildtool/file_system/file_root.test.cpp
@@ -374,89 +374,94 @@ TEST_CASE("Reading blob type", "[file_root]") {
}
}
-static void CheckLocalRoot(bool ignore_special) noexcept;
-static void CheckGitRoot(bool ignore_special) noexcept;
+static void CheckLocalRoot(HashFunction::Type hash_type,
+ bool ignore_special) noexcept;
+static void CheckGitRoot(HashFunction::Type hash_type,
+ bool ignore_special) noexcept;
TEST_CASE("Creating artifact descriptions", "[file_root]") {
+ auto const hash_type = ProtocolTraits::Instance().IsCompatible()
+ ? HashFunction::Type::PlainSHA256
+ : HashFunction::Type::GitSHA1;
+
SECTION("local root") {
- CheckLocalRoot(/*ignore_special=*/false);
+ CheckLocalRoot(hash_type, /*ignore_special=*/false);
}
SECTION("git root") {
- CheckGitRoot(/*ignore_special=*/false);
+ CheckGitRoot(hash_type, /*ignore_special=*/false);
}
SECTION("local root ignore-special") {
- CheckLocalRoot(/*ignore_special=*/true);
+ CheckLocalRoot(hash_type, /*ignore_special=*/true);
}
SECTION("git root ignore-special") {
- CheckGitRoot(/*ignore_special=*/true);
+ CheckGitRoot(hash_type, /*ignore_special=*/true);
}
}
-static void CheckLocalRoot(bool ignore_special) noexcept {
+static void CheckLocalRoot(HashFunction::Type hash_type,
+ bool ignore_special) noexcept {
auto const root_path = CreateTestRepoSymlinks(true);
REQUIRE(root_path);
auto const root = FileRoot{*root_path, ignore_special};
- auto const desc = root.ToArtifactDescription("baz/foo", "repo");
+ auto const desc = root.ToArtifactDescription(hash_type, "baz/foo", "repo");
REQUIRE(desc);
CHECK(*desc == ArtifactDescription::CreateLocal(
std::filesystem::path{"baz/foo"}, "repo"));
- CHECK(root.ToArtifactDescription("does_not_exist", "repo"));
+ CHECK(root.ToArtifactDescription(hash_type, "does_not_exist", "repo"));
}
-static void CheckGitRoot(bool ignore_special) noexcept {
+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);
REQUIRE(root);
- auto const foo = root->ToArtifactDescription("baz/foo", "repo");
+ auto const foo = root->ToArtifactDescription(hash_type, "baz/foo", "repo");
REQUIRE(foo);
- if (ProtocolTraits::Instance().IsCompatible()) {
- auto const digest =
- ArtifactDigestFactory::Create(HashFunction::Type::PlainSHA256,
- kFooIdSha256,
- kFooContentLength,
- /*is_tree=*/false);
+ if (not ProtocolTraits::IsNative(hash_type)) {
+ auto const digest = ArtifactDigestFactory::Create(hash_type,
+ kFooIdSha256,
+ kFooContentLength,
+ /*is_tree=*/false);
REQUIRE(digest);
CHECK(*foo ==
ArtifactDescription::CreateKnown(*digest, ObjectType::File));
}
else {
- auto const digest =
- ArtifactDigestFactory::Create(HashFunction::Type::GitSHA1,
- kFooIdGitSha1,
- kFooContentLength,
- /*is_tree=*/false);
+ auto const digest = ArtifactDigestFactory::Create(hash_type,
+ kFooIdGitSha1,
+ kFooContentLength,
+ /*is_tree=*/false);
REQUIRE(digest);
CHECK(*foo == ArtifactDescription::CreateKnown(
*digest, ObjectType::File, "repo"));
}
- auto const bar = root->ToArtifactDescription("baz/bar", "repo");
+ auto const bar = root->ToArtifactDescription(hash_type, "baz/bar", "repo");
REQUIRE(bar);
- if (ProtocolTraits::Instance().IsCompatible()) {
- auto const digest =
- ArtifactDigestFactory::Create(HashFunction::Type::PlainSHA256,
- kBarIdSha256,
- kBarContentLength,
- /*is_tree=*/false);
+ if (not ProtocolTraits::IsNative(hash_type)) {
+ auto const digest = ArtifactDigestFactory::Create(hash_type,
+ kBarIdSha256,
+ kBarContentLength,
+ /*is_tree=*/false);
REQUIRE(digest);
CHECK(*bar == ArtifactDescription::CreateKnown(*digest,
ObjectType::Executable));
}
else {
- auto const digest =
- ArtifactDigestFactory::Create(HashFunction::Type::GitSHA1,
- kBarIdGitSha1,
- kBarContentLength,
- /*is_tree=*/false);
+ auto const digest = ArtifactDigestFactory::Create(hash_type,
+ kBarIdGitSha1,
+ kBarContentLength,
+ /*is_tree=*/false);
REQUIRE(digest);
CHECK(*bar == ArtifactDescription::CreateKnown(
*digest, ObjectType::Executable, "repo"));
}
- CHECK_FALSE(root->ToArtifactDescription("baz", "repo"));
- CHECK_FALSE(root->ToArtifactDescription("does_not_exist", "repo"));
+ CHECK_FALSE(root->ToArtifactDescription(hash_type, "baz", "repo"));
+ CHECK_FALSE(
+ root->ToArtifactDescription(hash_type, "does_not_exist", "repo"));
}