summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-02 10:50:48 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-09 13:07:13 +0200
commit7eafe5779703275d455558120efc754c2dcc3c01 (patch)
treee31168069ef2460f187652157fe3c03be698d9a8 /test
parent50bcabb0717dae7c8411db59115c41b7cc636cb3 (diff)
downloadjustbuild-7eafe5779703275d455558120efc754c2dcc3c01.tar.gz
Replace ArtifactDigest::Create
...with ArtifactDigestFactory::HashDataAs
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/execution_api/bazel/TARGETS1
-rw-r--r--test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp9
-rw-r--r--test/buildtool/execution_api/common/TARGETS1
-rw-r--r--test/buildtool/execution_api/common/api_test.hpp13
-rw-r--r--test/buildtool/execution_api/local/TARGETS1
-rw-r--r--test/buildtool/execution_api/local/local_execution.test.cpp5
-rw-r--r--test/buildtool/execution_engine/executor/TARGETS1
-rw-r--r--test/buildtool/execution_engine/executor/executor_api.test.hpp24
-rw-r--r--test/buildtool/file_system/TARGETS1
-rw-r--r--test/buildtool/file_system/object_cas.test.cpp3
-rw-r--r--test/buildtool/storage/TARGETS1
-rw-r--r--test/buildtool/storage/local_ac.test.cpp13
-rw-r--r--test/buildtool/storage/local_cas.test.cpp2
13 files changed, 41 insertions, 34 deletions
diff --git a/test/buildtool/execution_api/bazel/TARGETS b/test/buildtool/execution_api/bazel/TARGETS
index 9d9aa5d8..192a6182 100644
--- a/test/buildtool/execution_api/bazel/TARGETS
+++ b/test/buildtool/execution_api/bazel/TARGETS
@@ -95,6 +95,7 @@
]
, ["@", "src", "src/buildtool/file_system", "object_type"]
, ["@", "src", "src/buildtool/common", "common"]
+ , ["@", "src", "src/buildtool/common", "artifact_digest_factory"]
, ["@", "src", "src/buildtool/crypto", "hash_function"]
, ["@", "src", "src/buildtool/compatibility", "compatibility"]
, ["@", "src", "src/buildtool/execution_api/common", "common"]
diff --git a/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp b/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp
index a775ef4d..40dec8da 100644
--- a/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp
+++ b/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp
@@ -22,6 +22,7 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_description.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
@@ -42,10 +43,10 @@ namespace {
if (not content.has_value()) {
return std::nullopt;
}
- return ArtifactBlob{
- ArtifactDigest::Create<ObjectType::File>(hash_function, *content),
- *content,
- IsExecutableObject(*type)};
+ return ArtifactBlob{ArtifactDigestFactory::HashDataAs<ObjectType::File>(
+ hash_function, *content),
+ *content,
+ IsExecutableObject(*type)};
}
} // namespace
diff --git a/test/buildtool/execution_api/common/TARGETS b/test/buildtool/execution_api/common/TARGETS
index c181447b..08ee9c39 100644
--- a/test/buildtool/execution_api/common/TARGETS
+++ b/test/buildtool/execution_api/common/TARGETS
@@ -12,6 +12,7 @@
, ["@", "src", "src/buildtool/logging", "logging"]
, ["@", "src", "src/buildtool/crypto", "hash_function"]
, ["@", "src", "src/buildtool/compatibility", "compatibility"]
+ , ["@", "src", "src/buildtool/common", "artifact_digest_factory"]
]
, "stage": ["test", "buildtool", "execution_api", "common"]
}
diff --git a/test/buildtool/execution_api/common/api_test.hpp b/test/buildtool/execution_api/common/api_test.hpp
index b93215a5..382760f6 100644
--- a/test/buildtool/execution_api/common/api_test.hpp
+++ b/test/buildtool/execution_api/common/api_test.hpp
@@ -24,6 +24,7 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_description.hpp"
+#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/common/execution_action.hpp"
@@ -143,8 +144,8 @@ using ExecProps = std::map<std::string, std::string>;
? HashFunction::Type::PlainSHA256
: HashFunction::Type::GitSHA1};
- auto test_digest =
- ArtifactDigest::Create<ObjectType::File>(hash_function, test_content);
+ auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
+ hash_function, test_content);
std::string output_path{"output_file"};
@@ -227,8 +228,8 @@ using ExecProps = std::map<std::string, std::string>;
? HashFunction::Type::PlainSHA256
: HashFunction::Type::GitSHA1};
- auto test_digest =
- ArtifactDigest::Create<ObjectType::File>(hash_function, test_content);
+ auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
+ hash_function, test_content);
auto input_artifact_opt =
ArtifactDescription::CreateKnown(test_digest, ObjectType::File)
@@ -318,8 +319,8 @@ using ExecProps = std::map<std::string, std::string>;
? HashFunction::Type::PlainSHA256
: HashFunction::Type::GitSHA1};
- auto test_digest =
- ArtifactDigest::Create<ObjectType::File>(hash_function, test_content);
+ auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
+ hash_function, test_content);
std::string output_path{"output_file"};
diff --git a/test/buildtool/execution_api/local/TARGETS b/test/buildtool/execution_api/local/TARGETS
index f88a8ff0..ec5498d8 100644
--- a/test/buildtool/execution_api/local/TARGETS
+++ b/test/buildtool/execution_api/local/TARGETS
@@ -6,6 +6,7 @@
[ ["@", "catch2", "", "catch2"]
, ["", "catch-main"]
, ["@", "src", "src/buildtool/common", "artifact_description"]
+ , ["@", "src", "src/buildtool/common", "artifact_digest_factory"]
, ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/local", "config"]
, ["@", "src", "src/buildtool/execution_api/local", "context"]
diff --git a/test/buildtool/execution_api/local/local_execution.test.cpp b/test/buildtool/execution_api/local/local_execution.test.cpp
index 49141076..120100de 100644
--- a/test/buildtool/execution_api/local/local_execution.test.cpp
+++ b/test/buildtool/execution_api/local/local_execution.test.cpp
@@ -20,6 +20,7 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_description.hpp"
+#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/execution_api/local/config.hpp"
#include "src/buildtool/execution_api/local/context.hpp"
@@ -189,7 +190,7 @@ TEST_CASE("LocalExecution: No input, create output", "[execution_api]") {
auto api = LocalApi(&local_context, &repo_config);
std::string test_content("test");
- auto test_digest = ArtifactDigest::Create<ObjectType::File>(
+ auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, test_content);
std::string output_path{"output_file"};
@@ -254,7 +255,7 @@ TEST_CASE("LocalExecution: One input copied to output", "[execution_api]") {
auto api = LocalApi(&local_context, &repo_config);
std::string test_content("test");
- auto test_digest = ArtifactDigest::Create<ObjectType::File>(
+ auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, test_content);
REQUIRE(api.Upload(ArtifactBlobContainer{{ArtifactBlob{
test_digest, test_content, /*is_exec=*/false}}},
diff --git a/test/buildtool/execution_engine/executor/TARGETS b/test/buildtool/execution_engine/executor/TARGETS
index bbdccc7c..cfe6ec23 100644
--- a/test/buildtool/execution_engine/executor/TARGETS
+++ b/test/buildtool/execution_engine/executor/TARGETS
@@ -6,6 +6,7 @@
[ ["@", "src", "src/buildtool/auth", "auth"]
, ["@", "src", "src/buildtool/common", "artifact_description"]
, ["@", "src", "src/buildtool/common", "common"]
+ , ["@", "src", "src/buildtool/common", "artifact_digest_factory"]
, ["@", "src", "src/buildtool/execution_api/common", "common"]
, ["@", "src", "src/buildtool/execution_api/remote", "config"]
, ["@", "src", "src/buildtool/execution_api/remote", "context"]
diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp
index 896279ef..24abbb78 100644
--- a/test/buildtool/execution_engine/executor/executor_api.test.hpp
+++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp
@@ -26,6 +26,7 @@
#include "gsl/gsl"
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/artifact_description.hpp"
+#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/common/remote/retry_config.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
@@ -60,12 +61,11 @@ static inline void RunBlobUpload(RepositoryConfig* repo_config,
: HashFunction::Type::GitSHA1};
std::string const blob = "test";
- CHECK(api->Upload(ArtifactBlobContainer{{ArtifactBlob{
- ArtifactDigest{hash_function.HashBlobData(blob).HexString(),
- blob.size(),
- /*is_tree=*/false},
- blob,
- /*is_exec=*/false}}}));
+ CHECK(api->Upload(ArtifactBlobContainer{
+ {ArtifactBlob{ArtifactDigestFactory::HashDataAs<ObjectType::File>(
+ hash_function, blob),
+ blob,
+ /*is_exec=*/false}}}));
}
[[nodiscard]] static inline auto GetTestDir() -> std::filesystem::path {
@@ -426,14 +426,10 @@ static inline void TestUploadAndDownloadTrees(
auto foo = std::string{"foo"};
auto bar = std::string{"bar"};
- auto foo_digest =
- ArtifactDigest{hash_function.HashBlobData(foo).HexString(),
- foo.size(),
- /*is_tree=*/false};
- auto bar_digest =
- ArtifactDigest{hash_function.HashBlobData(bar).HexString(),
- bar.size(),
- /*is_tree=*/false};
+ auto const foo_digest =
+ ArtifactDigestFactory::HashDataAs<ObjectType::File>(hash_function, foo);
+ auto const bar_digest =
+ ArtifactDigestFactory::HashDataAs<ObjectType::File>(hash_function, bar);
// upload blobs
auto api = factory();
diff --git a/test/buildtool/file_system/TARGETS b/test/buildtool/file_system/TARGETS
index a9632e48..8bc1dbe4 100644
--- a/test/buildtool/file_system/TARGETS
+++ b/test/buildtool/file_system/TARGETS
@@ -24,6 +24,7 @@
, ["@", "src", "src/buildtool/file_system", "object_cas"]
, ["@", "src", "src/buildtool/file_system", "object_type"]
, ["@", "src", "src/buildtool/common", "common"]
+ , ["@", "src", "src/buildtool/common", "artifact_digest_factory"]
, ["@", "src", "src/buildtool/storage", "config"]
, ["utils", "test_storage_config"]
]
diff --git a/test/buildtool/file_system/object_cas.test.cpp b/test/buildtool/file_system/object_cas.test.cpp
index 58e011a0..6f06eea4 100644
--- a/test/buildtool/file_system/object_cas.test.cpp
+++ b/test/buildtool/file_system/object_cas.test.cpp
@@ -19,6 +19,7 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/storage/config.hpp"
@@ -29,7 +30,7 @@ TEST_CASE("ObjectCAS", "[file_system]") {
auto gen_config = storage_config.Get().CreateGenerationConfig(0);
std::string test_content{"test"};
- auto test_digest = ArtifactDigest::Create<ObjectType::File>(
+ auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, test_content);
SECTION("CAS for files") {
diff --git a/test/buildtool/storage/TARGETS b/test/buildtool/storage/TARGETS
index b5d88715..5eeafa9a 100644
--- a/test/buildtool/storage/TARGETS
+++ b/test/buildtool/storage/TARGETS
@@ -36,6 +36,7 @@
, ["", "catch-main"]
, ["@", "src", "src/buildtool/common", "bazel_types"]
, ["@", "src", "src/buildtool/common", "common"]
+ , ["@", "src", "src/buildtool/common", "artifact_digest_factory"]
, ["@", "src", "src/buildtool/file_system", "file_system_manager"]
, ["@", "src", "src/buildtool/file_system", "object_type"]
, ["@", "src", "src/buildtool/storage", "storage"]
diff --git a/test/buildtool/storage/local_ac.test.cpp b/test/buildtool/storage/local_ac.test.cpp
index 9923108d..543a09b5 100644
--- a/test/buildtool/storage/local_ac.test.cpp
+++ b/test/buildtool/storage/local_ac.test.cpp
@@ -17,6 +17,7 @@
#include "catch2/catch_test_macros.hpp"
#include "gsl/gsl"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/common/artifact_digest_factory.hpp"
#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/object_type.hpp"
@@ -36,7 +37,7 @@ TEST_CASE("LocalAC: Single action, single result", "[storage]") {
auto const& ac = storage.ActionCache();
auto const& cas = storage.CAS();
- auto action_id = ArtifactDigest::Create<ObjectType::File>(
+ auto action_id = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, "action");
CHECK(not ac.CachedResult(action_id));
CHECK(RunDummyExecution(&ac, &cas, action_id, "result"));
@@ -51,9 +52,9 @@ TEST_CASE("LocalAC: Two different actions, two different results",
auto const& ac = storage.ActionCache();
auto const& cas = storage.CAS();
- auto action_id1 = ArtifactDigest::Create<ObjectType::File>(
+ auto action_id1 = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, "action1");
- auto action_id2 = ArtifactDigest::Create<ObjectType::File>(
+ auto action_id2 = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, "action2");
CHECK(not ac.CachedResult(action_id1));
CHECK(not ac.CachedResult(action_id2));
@@ -82,9 +83,9 @@ TEST_CASE("LocalAC: Two different actions, same two results", "[storage]") {
auto const& ac = storage.ActionCache();
auto const& cas = storage.CAS();
- auto action_id1 = ArtifactDigest::Create<ObjectType::File>(
+ auto action_id1 = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, "action1");
- auto action_id2 = ArtifactDigest::Create<ObjectType::File>(
+ auto action_id2 = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, "action2");
CHECK(not ac.CachedResult(action_id1));
CHECK(not ac.CachedResult(action_id2));
@@ -113,7 +114,7 @@ TEST_CASE("LocalAC: Same two actions, two different results", "[storage]") {
auto const& ac = storage.ActionCache();
auto const& cas = storage.CAS();
- auto action_id = ArtifactDigest::Create<ObjectType::File>(
+ auto action_id = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, "same action");
CHECK(not ac.CachedResult(action_id));
diff --git a/test/buildtool/storage/local_cas.test.cpp b/test/buildtool/storage/local_cas.test.cpp
index 44371fea..c7b7f720 100644
--- a/test/buildtool/storage/local_cas.test.cpp
+++ b/test/buildtool/storage/local_cas.test.cpp
@@ -32,7 +32,7 @@ TEST_CASE("LocalCAS: Add blob to storage from bytes", "[storage]") {
std::string test_bytes("test");
- auto test_digest = ArtifactDigest::Create<ObjectType::File>(
+ auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
storage_config.Get().hash_function, test_bytes);
// check blob not in storage