summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-12 14:39:05 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-13 14:41:00 +0200
commitd0d5921cf92ea15464f9ff4856c34b026a30ffb0 (patch)
tree1593302ecd9ef1d5274a55e50fd3e4f5a8f60179 /test
parent5fb67de531fead44123ff30ee5cf37340fc63a0b (diff)
downloadjustbuild-d0d5921cf92ea15464f9ff4856c34b026a30ffb0.tar.gz
Remove Compatibility flag from tests
Diffstat (limited to 'test')
-rw-r--r--test/main.cpp3
-rw-r--r--test/utils/TARGETS4
-rw-r--r--test/utils/hermeticity/test_hash_function_type.hpp18
-rw-r--r--test/utils/remote_execution/main-remote-execution.cpp3
-rw-r--r--test/utils/serve_service/main-serve.cpp3
-rw-r--r--test/utils/test_env.hpp10
6 files changed, 23 insertions, 18 deletions
diff --git a/test/main.cpp b/test/main.cpp
index f73045dc..54afa2dc 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -20,12 +20,9 @@
#include "src/buildtool/file_system/git_context.hpp"
#include "src/buildtool/storage/file_chunker.hpp"
#include "test/utils/logging/log_config.hpp"
-#include "test/utils/test_env.hpp"
auto main(int argc, char* argv[]) -> int {
ConfigureLogging();
- ReadCompatibilityFromEnv();
-
/**
* The current implementation of libgit2 uses pthread_key_t incorrectly
* on POSIX systems to handle thread-specific data, which requires us to
diff --git a/test/utils/TARGETS b/test/utils/TARGETS
index ffded132..6a5fd59a 100644
--- a/test/utils/TARGETS
+++ b/test/utils/TARGETS
@@ -64,7 +64,9 @@
, "hdrs": ["hermeticity/test_hash_function_type.hpp"]
, "deps":
[ ["@", "src", "src/buildtool/crypto", "hash_function"]
- , ["@", "src", "src/buildtool/common", "protocol_traits"]
+ , ["@", "src", "src/buildtool/logging", "log_level"]
+ , ["@", "src", "src/buildtool/logging", "logging"]
+ , "test_env"
]
, "stage": ["test", "utils"]
}
diff --git a/test/utils/hermeticity/test_hash_function_type.hpp b/test/utils/hermeticity/test_hash_function_type.hpp
index 14c89d4a..ab46f791 100644
--- a/test/utils/hermeticity/test_hash_function_type.hpp
+++ b/test/utils/hermeticity/test_hash_function_type.hpp
@@ -15,16 +15,26 @@
#ifndef INCLUDED_SRC_TEST_UTILS_HERMETICITY_TEST_HASH_FUNCTION_TYPE_HPP
#define INCLUDED_SRC_TEST_UTILS_HERMETICITY_TEST_HASH_FUNCTION_TYPE_HPP
-#include "src/buildtool/common/protocol_traits.hpp"
+#include <cstddef> //std::exit
+#include <optional>
+
#include "src/buildtool/crypto/hash_function.hpp"
+#include "src/buildtool/logging/log_level.hpp"
+#include "src/buildtool/logging/logger.hpp"
+#include "test/utils/test_env.hpp"
class TestHashType final {
public:
[[nodiscard]] static auto ReadFromEnvironment() noexcept
-> HashFunction::Type {
- return ProtocolTraits::Instance().IsCompatible()
- ? HashFunction::Type::PlainSHA256
- : HashFunction::Type::GitSHA1;
+ auto const compatible = ReadCompatibilityFromEnv();
+ if (not compatible) {
+ Logger::Log(LogLevel::Error,
+ "Failed to read COMPATIBLE from environment");
+ std::exit(EXIT_FAILURE);
+ }
+ return *compatible ? HashFunction::Type::PlainSHA256
+ : HashFunction::Type::GitSHA1;
}
};
diff --git a/test/utils/remote_execution/main-remote-execution.cpp b/test/utils/remote_execution/main-remote-execution.cpp
index 45021c61..f7bbc4fc 100644
--- a/test/utils/remote_execution/main-remote-execution.cpp
+++ b/test/utils/remote_execution/main-remote-execution.cpp
@@ -29,7 +29,6 @@
#include "test/utils/logging/log_config.hpp"
#include "test/utils/remote_execution/test_auth_config.hpp"
#include "test/utils/remote_execution/test_remote_config.hpp"
-#include "test/utils/test_env.hpp"
namespace {
@@ -42,8 +41,6 @@ void wait_for_grpc_to_shutdown() {
/// environment variable is malformed, we write a message and stop execution.
/// \returns true If remote execution was successfully configured.
void ConfigureRemoteExecution() {
- ReadCompatibilityFromEnv();
-
// Ensure authentication config is available
if (not TestAuthConfig::ReadFromEnvironment()) {
std::exit(EXIT_FAILURE);
diff --git a/test/utils/serve_service/main-serve.cpp b/test/utils/serve_service/main-serve.cpp
index 2868e354..1f40de08 100644
--- a/test/utils/serve_service/main-serve.cpp
+++ b/test/utils/serve_service/main-serve.cpp
@@ -33,7 +33,6 @@
#include "test/utils/logging/log_config.hpp"
#include "test/utils/serve_service/test_serve_config.hpp"
#include "test/utils/shell_quoting.hpp"
-#include "test/utils/test_env.hpp"
namespace {
@@ -110,8 +109,6 @@ void wait_for_grpc_to_shutdown() {
auto main(int argc, char* argv[]) -> int {
ConfigureLogging();
- ReadCompatibilityFromEnv();
-
// Setup of serve service, including known repositories.
if (not ConfigureServeService()) {
return EXIT_FAILURE;
diff --git a/test/utils/test_env.hpp b/test/utils/test_env.hpp
index fc6ac739..ec03a9ee 100644
--- a/test/utils/test_env.hpp
+++ b/test/utils/test_env.hpp
@@ -40,10 +40,12 @@
return properties;
}
-static inline void ReadCompatibilityFromEnv() {
- auto* compatible = std::getenv("COMPATIBLE");
- if (compatible != nullptr) {
- ProtocolTraits::Instance().SetCompatible();
+[[nodiscard]] static inline auto ReadCompatibilityFromEnv() noexcept
+ -> std::optional<bool> {
+ try {
+ return std::getenv("COMPATIBLE") != nullptr;
+ } catch (...) {
+ return std::nullopt;
}
}