summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/bazel/bazel_api.test.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-12 14:28:13 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-13 14:41:00 +0200
commit5fb67de531fead44123ff30ee5cf37340fc63a0b (patch)
tree0e1c7c8810e8ee311467e5e07ebb8ff2902adf28 /test/buildtool/execution_api/bazel/bazel_api.test.cpp
parentdd15af0ba4b22348e38d535aadc9fa5e929f3824 (diff)
downloadjustbuild-5fb67de531fead44123ff30ee5cf37340fc63a0b.tar.gz
Use TestHashType in tests
...instead of calling ProtocolTraits::IsCompatible
Diffstat (limited to 'test/buildtool/execution_api/bazel/bazel_api.test.cpp')
-rw-r--r--test/buildtool/execution_api/bazel/bazel_api.test.cpp50
1 files changed, 17 insertions, 33 deletions
diff --git a/test/buildtool/execution_api/bazel/bazel_api.test.cpp b/test/buildtool/execution_api/bazel/bazel_api.test.cpp
index 5dc4198d..16c45aae 100644
--- a/test/buildtool/execution_api/bazel/bazel_api.test.cpp
+++ b/test/buildtool/execution_api/bazel/bazel_api.test.cpp
@@ -18,11 +18,11 @@
#include <string>
#include "catch2/catch_test_macros.hpp"
-#include "src/buildtool/common/protocol_traits.hpp"
#include "src/buildtool/common/remote/retry_config.hpp"
#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "test/buildtool/execution_api/common/api_test.hpp"
+#include "test/utils/hermeticity/test_hash_function_type.hpp"
#include "test/utils/remote_execution/test_auth_config.hpp"
#include "test/utils/remote_execution/test_remote_config.hpp"
@@ -59,15 +59,13 @@ class FactoryApi final {
TEST_CASE("BazelAPI: No input, no output", "[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestNoInputNoOutput(api_factory, remote_config->platform_properties);
@@ -75,15 +73,13 @@ TEST_CASE("BazelAPI: No input, no output", "[execution_api]") {
TEST_CASE("BazelAPI: No input, create output", "[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestNoInputCreateOutput(api_factory, remote_config->platform_properties);
@@ -91,15 +87,13 @@ TEST_CASE("BazelAPI: No input, create output", "[execution_api]") {
TEST_CASE("BazelAPI: One input copied to output", "[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestOneInputCopiedToOutput(api_factory, remote_config->platform_properties);
@@ -107,15 +101,13 @@ TEST_CASE("BazelAPI: One input copied to output", "[execution_api]") {
TEST_CASE("BazelAPI: Non-zero exit code, create output", "[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestNonZeroExitCodeCreateOutput(api_factory,
@@ -124,15 +116,13 @@ TEST_CASE("BazelAPI: Non-zero exit code, create output", "[execution_api]") {
TEST_CASE("BazelAPI: Retrieve two identical trees to path", "[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestRetrieveTwoIdenticalTreesToPath(
@@ -142,15 +132,13 @@ TEST_CASE("BazelAPI: Retrieve two identical trees to path", "[execution_api]") {
TEST_CASE("BazelAPI: Retrieve file and symlink with same content to path",
"[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestRetrieveFileAndSymlinkWithSameContentToPath(
@@ -159,15 +147,13 @@ TEST_CASE("BazelAPI: Retrieve file and symlink with same content to path",
TEST_CASE("BazelAPI: Retrieve mixed blobs and trees", "[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestRetrieveMixedBlobsAndTrees(
@@ -176,15 +162,13 @@ TEST_CASE("BazelAPI: Retrieve mixed blobs and trees", "[execution_api]") {
TEST_CASE("BazelAPI: Create directory prior to execution", "[execution_api]") {
auto remote_config = TestRemoteConfig::ReadFromEnvironment();
+ HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
+
REQUIRE(remote_config);
REQUIRE(remote_config->remote_address);
auto auth = TestAuthConfig::ReadFromEnvironment();
REQUIRE(auth);
- HashFunction const hash_function{ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1};
-
FactoryApi api_factory{
&*remote_config->remote_address, &*auth, hash_function};
TestCreateDirPriorToExecution(api_factory,