summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/build_engine/base_maps/TARGETS3
-rw-r--r--test/buildtool/build_engine/base_maps/directory_map.test.cpp13
-rw-r--r--test/buildtool/build_engine/base_maps/expression_map.test.cpp15
-rw-r--r--test/buildtool/build_engine/base_maps/json_file_map.test.cpp14
-rw-r--r--test/buildtool/build_engine/base_maps/rule_map.test.cpp21
-rw-r--r--test/buildtool/build_engine/base_maps/source_map.test.cpp17
-rw-r--r--test/buildtool/build_engine/target_map/target_map.test.cpp215
-rw-r--r--test/buildtool/common/repository_config.test.cpp12
-rw-r--r--test/buildtool/execution_api/local/TARGETS1
-rwxr-xr-xtest/buildtool/execution_api/local/local_execution.test.cpp16
-rw-r--r--test/buildtool/execution_engine/executor/TARGETS3
-rw-r--r--test/buildtool/execution_engine/executor/executor.test.cpp36
-rwxr-xr-xtest/buildtool/execution_engine/executor/executor_api.test.hpp113
-rwxr-xr-xtest/buildtool/execution_engine/executor/executor_api_local.test.cpp21
-rwxr-xr-xtest/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp12
-rw-r--r--test/buildtool/graph_traverser/graph_traverser.test.hpp38
16 files changed, 340 insertions, 210 deletions
diff --git a/test/buildtool/build_engine/base_maps/TARGETS b/test/buildtool/build_engine/base_maps/TARGETS
index 862aa3dc..9a71957d 100644
--- a/test/buildtool/build_engine/base_maps/TARGETS
+++ b/test/buildtool/build_engine/base_maps/TARGETS
@@ -43,6 +43,7 @@
[ "test_repo"
, ["@", "catch2", "", "catch2"]
, ["", "catch-main"]
+ , ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/build_engine/base_maps", "json_file_map"]
]
, "stage": ["test", "buildtool", "build_engine", "base_maps"]
@@ -56,6 +57,7 @@
[ "test_repo"
, ["@", "catch2", "", "catch2"]
, ["", "catch-main"]
+ , ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/build_engine/base_maps", "directory_map"]
, ["@", "src", "src/buildtool/build_engine/base_maps", "source_map"]
]
@@ -83,6 +85,7 @@
[ "test_repo"
, ["@", "catch2", "", "catch2"]
, ["", "catch-main"]
+ , ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/build_engine/base_maps", "rule_map"]
]
, "stage": ["test", "buildtool", "build_engine", "base_maps"]
diff --git a/test/buildtool/build_engine/base_maps/directory_map.test.cpp b/test/buildtool/build_engine/base_maps/directory_map.test.cpp
index e05e5269..b2674c2b 100644
--- a/test/buildtool/build_engine/base_maps/directory_map.test.cpp
+++ b/test/buildtool/build_engine/base_maps/directory_map.test.cpp
@@ -13,6 +13,7 @@
// limitations under the License.
#include <filesystem>
+#include <memory>
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/build_engine/base_maps/directory_map.hpp"
@@ -24,7 +25,7 @@ namespace {
using namespace BuildMaps::Base; // NOLINT
-void SetupConfig(bool use_git) {
+auto SetupConfig(bool use_git) -> RepositoryConfig {
auto root = FileRoot{kBasePath / "data_src"};
if (use_git) {
auto repo_path = CreateTestRepo();
@@ -33,16 +34,16 @@ void SetupConfig(bool use_git) {
REQUIRE(git_root);
root = std::move(*git_root);
}
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo(
- "", RepositoryConfig::RepositoryInfo{root});
+ RepositoryConfig repo_config{};
+ repo_config.SetInfo("", RepositoryConfig::RepositoryInfo{root});
+ return repo_config;
}
auto ReadDirectory(ModuleName const& id,
DirectoryEntriesMap::Consumer value_checker,
bool use_git = false) -> bool {
- SetupConfig(use_git);
- auto data_direntries = CreateDirectoryEntriesMap();
+ auto repo_config = SetupConfig(use_git);
+ auto data_direntries = CreateDirectoryEntriesMap(&repo_config);
bool success{true};
{
TaskSystem ts;
diff --git a/test/buildtool/build_engine/base_maps/expression_map.test.cpp b/test/buildtool/build_engine/base_maps/expression_map.test.cpp
index 89b73d33..392d81ba 100644
--- a/test/buildtool/build_engine/base_maps/expression_map.test.cpp
+++ b/test/buildtool/build_engine/base_maps/expression_map.test.cpp
@@ -14,6 +14,7 @@
#include <filesystem>
#include <functional>
+#include <memory>
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/build_engine/base_maps/expression_map.hpp"
@@ -26,7 +27,7 @@ namespace {
using namespace BuildMaps::Base; // NOLINT
-void SetupConfig(bool use_git) {
+auto SetupConfig(bool use_git) -> RepositoryConfig {
auto root = FileRoot{kBasePath / "data_expr"};
if (use_git) {
auto repo_path = CreateTestRepo();
@@ -35,17 +36,17 @@ void SetupConfig(bool use_git) {
REQUIRE(git_root);
root = std::move(*git_root);
}
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo(
- "", RepositoryConfig::RepositoryInfo{root});
+ RepositoryConfig repo_config{};
+ repo_config.SetInfo("", RepositoryConfig::RepositoryInfo{root});
+ return repo_config;
}
auto ReadExpressionFunction(EntityName const& id,
ExpressionFunctionMap::Consumer value_checker,
bool use_git = false) -> bool {
- SetupConfig(use_git);
- auto expr_file_map = CreateExpressionFileMap(0);
- auto expr_func_map = CreateExpressionMap(&expr_file_map);
+ auto repo_config = SetupConfig(use_git);
+ auto expr_file_map = CreateExpressionFileMap(&repo_config, 0);
+ auto expr_func_map = CreateExpressionMap(&expr_file_map, &repo_config);
bool success{true};
{
diff --git a/test/buildtool/build_engine/base_maps/json_file_map.test.cpp b/test/buildtool/build_engine/base_maps/json_file_map.test.cpp
index 15ff87cd..e0177864 100644
--- a/test/buildtool/build_engine/base_maps/json_file_map.test.cpp
+++ b/test/buildtool/build_engine/base_maps/json_file_map.test.cpp
@@ -13,10 +13,12 @@
// limitations under the License.
#include <filesystem>
+#include <memory>
#include <utility>
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/build_engine/base_maps/json_file_map.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
#include "test/buildtool/build_engine/base_maps/test_repo.hpp"
@@ -24,7 +26,8 @@ namespace {
using namespace BuildMaps::Base; // NOLINT
-void SetupConfig(std::string target_file_name, bool use_git) {
+auto SetupConfig(std::string target_file_name, bool use_git)
+ -> RepositoryConfig {
auto root = FileRoot{kBasePath};
if (use_git) {
auto repo_path = CreateTestRepo();
@@ -35,8 +38,9 @@ void SetupConfig(std::string target_file_name, bool use_git) {
}
auto info = RepositoryConfig::RepositoryInfo{root};
info.target_file_name = std::move(target_file_name);
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo("", std::move(info));
+ RepositoryConfig repo_config{};
+ repo_config.SetInfo("", std::move(info));
+ return repo_config;
}
template <bool kMandatory = true>
@@ -46,10 +50,10 @@ auto ReadJsonFile(std::string const& target_file_name,
bool use_git = false,
std::optional<JsonFileMap::FailureFunction> fail_func =
std::nullopt) -> bool {
- SetupConfig(target_file_name, use_git);
+ auto repo_config = SetupConfig(target_file_name, use_git);
auto json_files = CreateJsonFileMap<&RepositoryConfig::WorkspaceRoot,
&RepositoryConfig::TargetFileName,
- kMandatory>(0);
+ kMandatory>(&repo_config, 0);
bool success{true};
{
TaskSystem ts;
diff --git a/test/buildtool/build_engine/base_maps/rule_map.test.cpp b/test/buildtool/build_engine/base_maps/rule_map.test.cpp
index 4235d1f1..7a3a021f 100644
--- a/test/buildtool/build_engine/base_maps/rule_map.test.cpp
+++ b/test/buildtool/build_engine/base_maps/rule_map.test.cpp
@@ -14,11 +14,13 @@
#include <filesystem>
#include <functional>
+#include <memory>
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/build_engine/base_maps/expression_map.hpp"
#include "src/buildtool/build_engine/base_maps/json_file_map.hpp"
#include "src/buildtool/build_engine/base_maps/rule_map.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
#include "test/buildtool/build_engine/base_maps/test_repo.hpp"
@@ -26,7 +28,7 @@ namespace {
using namespace BuildMaps::Base; // NOLINT
-void SetupConfig(bool use_git) {
+auto SetupConfig(bool use_git) -> RepositoryConfig {
auto root = FileRoot{kBasePath / "data_rule"};
if (use_git) {
auto repo_path = CreateTestRepo();
@@ -35,19 +37,20 @@ void SetupConfig(bool use_git) {
REQUIRE(git_root);
root = std::move(*git_root);
}
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo(
- "", RepositoryConfig::RepositoryInfo{root});
+ RepositoryConfig repo_config{};
+ repo_config.SetInfo("", RepositoryConfig::RepositoryInfo{root});
+ return repo_config;
}
auto ReadUserRule(EntityName const& id,
UserRuleMap::Consumer value_checker,
bool use_git = false) -> bool {
- SetupConfig(use_git);
- auto expr_file_map = CreateExpressionFileMap(0);
- auto expr_func_map = CreateExpressionMap(&expr_file_map);
- auto rule_file_map = CreateRuleFileMap(0);
- auto user_rule_map = CreateRuleMap(&rule_file_map, &expr_func_map);
+ auto repo_config = SetupConfig(use_git);
+ auto expr_file_map = CreateExpressionFileMap(&repo_config, 0);
+ auto expr_func_map = CreateExpressionMap(&expr_file_map, &repo_config);
+ auto rule_file_map = CreateRuleFileMap(&repo_config, 0);
+ auto user_rule_map =
+ CreateRuleMap(&rule_file_map, &expr_func_map, &repo_config);
bool success{true};
{
diff --git a/test/buildtool/build_engine/base_maps/source_map.test.cpp b/test/buildtool/build_engine/base_maps/source_map.test.cpp
index 05157870..b61bcbd4 100644
--- a/test/buildtool/build_engine/base_maps/source_map.test.cpp
+++ b/test/buildtool/build_engine/base_maps/source_map.test.cpp
@@ -13,12 +13,14 @@
// limitations under the License.
#include <filesystem>
+#include <memory>
#include <utility>
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/build_engine/base_maps/directory_map.hpp"
#include "src/buildtool/build_engine/base_maps/entity_name.hpp"
#include "src/buildtool/build_engine/base_maps/source_map.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
#include "test/buildtool/build_engine/base_maps/test_repo.hpp"
@@ -27,7 +29,7 @@ namespace {
using namespace BuildMaps::Base; // NOLINT
-void SetupConfig(bool use_git) {
+auto SetupConfig(bool use_git) -> RepositoryConfig {
// manually create locally a test symlink in data_src; should match the
// git test_repo structure
if (not use_git) {
@@ -44,9 +46,9 @@ void SetupConfig(bool use_git) {
REQUIRE(git_root);
root = std::move(*git_root);
}
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo(
- "", RepositoryConfig::RepositoryInfo{root});
+ RepositoryConfig repo_config{};
+ repo_config.SetInfo("", RepositoryConfig::RepositoryInfo{root});
+ return repo_config;
}
auto ReadSourceTarget(
@@ -55,9 +57,10 @@ auto ReadSourceTarget(
bool use_git = false,
std::optional<SourceTargetMap::FailureFunction> fail_func = std::nullopt)
-> bool {
- SetupConfig(use_git);
- auto directory_entries = CreateDirectoryEntriesMap();
- auto source_artifacts = CreateSourceTargetMap(&directory_entries);
+ auto repo_config = SetupConfig(use_git);
+ auto directory_entries = CreateDirectoryEntriesMap(&repo_config);
+ auto source_artifacts =
+ CreateSourceTargetMap(&directory_entries, &repo_config);
std::string error_msg;
bool success{true};
{
diff --git a/test/buildtool/build_engine/target_map/target_map.test.cpp b/test/buildtool/build_engine/target_map/target_map.test.cpp
index d9144dfb..14701f6c 100644
--- a/test/buildtool/build_engine/target_map/target_map.test.cpp
+++ b/test/buildtool/build_engine/target_map/target_map.test.cpp
@@ -44,7 +44,7 @@ auto CreateSymlinks() -> bool {
return true;
}
-void SetupConfig() {
+auto SetupConfig() -> RepositoryConfig {
// manually create locally test symlinks in data_src, but only once
[[maybe_unused]] static auto done = CreateSymlinks();
// create the file roots
@@ -57,31 +57,38 @@ void SetupConfig() {
"data_rules"}},
FileRoot{std::filesystem::path{"test/buildtool/build_engine/target_map/"
"data_expr"}}};
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo("", std::move(info));
+ RepositoryConfig repo_config{};
+ repo_config.SetInfo("", std::move(info));
+ return repo_config;
}
} // namespace
TEST_CASE("simple targets") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
AnalysedTargetPtr result;
bool error{false};
@@ -403,24 +410,30 @@ TEST_CASE("simple targets") {
}
TEST_CASE("configuration deduplication") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
std::vector<AnalysedTargetPtr> result;
bool error{false};
@@ -464,24 +477,30 @@ TEST_CASE("configuration deduplication") {
}
TEST_CASE("generator functions in string arguments") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
AnalysedTargetPtr result;
bool error{false};
@@ -538,24 +557,30 @@ TEST_CASE("generator functions in string arguments") {
}
TEST_CASE("built-in rules") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
AnalysedTargetPtr result;
bool error{false};
std::string error_msg;
@@ -722,24 +747,30 @@ TEST_CASE("built-in rules") {
}
TEST_CASE("target reference") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
AnalysedTargetPtr result;
bool error{false};
@@ -839,24 +870,30 @@ TEST_CASE("target reference") {
}
TEST_CASE("trees") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
AnalysedTargetPtr result;
bool error{false};
@@ -920,24 +957,30 @@ TEST_CASE("trees") {
}
TEST_CASE("RESULT error reporting") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
AnalysedTargetPtr result;
bool error{false};
@@ -1060,24 +1103,30 @@ TEST_CASE("RESULT error reporting") {
}
TEST_CASE("wrong arguments") {
- SetupConfig();
- auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap();
- auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries);
- auto targets_file_map = BuildMaps::Base::CreateTargetsFileMap(0);
- auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(0);
+ auto repo_config = SetupConfig();
+ auto directory_entries =
+ BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config);
+ auto source = BuildMaps::Base::CreateSourceTargetMap(&directory_entries,
+ &repo_config);
+ auto targets_file_map =
+ BuildMaps::Base::CreateTargetsFileMap(&repo_config, 0);
+ auto rule_file_map = BuildMaps::Base::CreateRuleFileMap(&repo_config, 0);
static auto expressions_file_map =
- BuildMaps::Base::CreateExpressionFileMap(0);
- auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map);
- auto rule_map = BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map);
+ BuildMaps::Base::CreateExpressionFileMap(&repo_config, 0);
+ auto expr_map = BuildMaps::Base::CreateExpressionMap(&expressions_file_map,
+ &repo_config);
+ auto rule_map =
+ BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, 0);
+ BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
auto target_map = BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
&rule_map,
&directory_entries,
&absent_target_map,
- &result_map);
+ &result_map,
+ &repo_config);
AnalysedTargetPtr result;
bool error{false};
diff --git a/test/buildtool/common/repository_config.test.cpp b/test/buildtool/common/repository_config.test.cpp
index cfde95ed..6eaec044 100644
--- a/test/buildtool/common/repository_config.test.cpp
+++ b/test/buildtool/common/repository_config.test.cpp
@@ -104,8 +104,7 @@ template <class T>
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Test missing repository",
"[repository_config]") {
- auto& config = RepositoryConfig::Instance();
- config.Reset();
+ RepositoryConfig config{};
CHECK(config.Info("missing") == nullptr);
CHECK_FALSE(config.RepositoryKey("missing"));
@@ -114,8 +113,7 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Compute key of fixed repository",
"[repository_config]") {
- auto& config = RepositoryConfig::Instance();
- config.Reset();
+ RepositoryConfig config{};
SECTION("for single fixed repository") {
config.SetInfo("foo", CreateFixedRepoInfo());
@@ -144,8 +142,7 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Compute key of file repository",
"[repository_config]") {
- auto& config = RepositoryConfig::Instance();
- config.Reset();
+ RepositoryConfig config{};
SECTION("for single file repository") {
config.SetInfo("foo", CreateFileRepoInfo());
@@ -163,8 +160,7 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Compare key of two repos with same content",
"[repository_config]") {
- auto& config = RepositoryConfig::Instance();
- config.Reset();
+ RepositoryConfig config{};
// create two different repo infos with same content (baz should be same)
config.SetInfo("foo", CreateFixedRepoInfo({{"dep", "baz0"}}));
diff --git a/test/buildtool/execution_api/local/TARGETS b/test/buildtool/execution_api/local/TARGETS
index 11e92a45..a4b2821a 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_factory"]
+ , ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/local", "local"]
, ["utils", "local_hermeticity"]
]
diff --git a/test/buildtool/execution_api/local/local_execution.test.cpp b/test/buildtool/execution_api/local/local_execution.test.cpp
index 9dbed876..36615d89 100755
--- a/test/buildtool/execution_api/local/local_execution.test.cpp
+++ b/test/buildtool/execution_api/local/local_execution.test.cpp
@@ -18,6 +18,7 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_factory.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
#include "test/utils/hermeticity/local.hpp"
@@ -37,7 +38,8 @@ namespace {
TEST_CASE_METHOD(HermeticLocalTestFixture,
"LocalExecution: No input, no output",
"[execution_api]") {
- auto api = LocalApi{};
+ RepositoryConfig repo_config{};
+ auto api = LocalApi(&repo_config);
std::string test_content("test");
std::vector<std::string> const cmdline = {"echo", "-n", test_content};
@@ -80,7 +82,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
TEST_CASE_METHOD(HermeticLocalTestFixture,
"LocalExecution: No input, no output, env variables used",
"[execution_api]") {
- auto api = LocalApi{};
+ RepositoryConfig repo_config{};
+ auto api = LocalApi(&repo_config);
std::string test_content("test from env var");
std::vector<std::string> const cmdline = {
@@ -129,7 +132,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
TEST_CASE_METHOD(HermeticLocalTestFixture,
"LocalExecution: No input, create output",
"[execution_api]") {
- auto api = LocalApi{};
+ RepositoryConfig repo_config{};
+ auto api = LocalApi(&repo_config);
std::string test_content("test");
auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content);
@@ -184,7 +188,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
TEST_CASE_METHOD(HermeticLocalTestFixture,
"LocalExecution: One input copied to output",
"[execution_api]") {
- auto api = LocalApi{};
+ RepositoryConfig repo_config{};
+ auto api = LocalApi(&repo_config);
std::string test_content("test");
auto test_digest = ArtifactDigest::Create<ObjectType::File>(test_content);
@@ -253,7 +258,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
TEST_CASE_METHOD(HermeticLocalTestFixture,
"LocalExecution: Cache failed action's result",
"[execution_api]") {
- auto api = LocalApi{};
+ RepositoryConfig repo_config{};
+ auto api = LocalApi(&repo_config);
auto flag = GetTestDir() / "flag";
std::vector<std::string> const cmdline = {
diff --git a/test/buildtool/execution_engine/executor/TARGETS b/test/buildtool/execution_engine/executor/TARGETS
index a3e97d89..991cecc3 100644
--- a/test/buildtool/execution_engine/executor/TARGETS
+++ b/test/buildtool/execution_engine/executor/TARGETS
@@ -10,6 +10,7 @@
, "srcs": ["executor.test.cpp"]
, "private-deps":
[ ["@", "src", "src/buildtool/common", "artifact_factory"]
+ , ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/common", "common"]
, ["@", "src", "src/buildtool/execution_engine/dag", "dag"]
, ["@", "src", "src/buildtool/execution_engine/executor", "executor"]
@@ -26,6 +27,7 @@
, "private-deps":
[ "executor_api_tests"
, ["@", "src", "src/buildtool/common", "artifact_factory"]
+ , ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/local", "local"]
, ["@", "src", "src/buildtool/execution_api/remote", "config"]
, ["@", "src", "src/buildtool/execution_engine/dag", "dag"]
@@ -44,6 +46,7 @@
, "private-deps":
[ "executor_api_tests"
, ["@", "src", "src/buildtool/common", "artifact_factory"]
+ , ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/remote", "bazel"]
, ["@", "src", "src/buildtool/execution_api/remote", "config"]
, ["@", "src", "src/buildtool/execution_engine/executor", "executor"]
diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp
index 0df8bd0f..55417016 100644
--- a/test/buildtool/execution_engine/executor/executor.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor.test.cpp
@@ -18,6 +18,7 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_factory.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
@@ -205,17 +206,18 @@ class TestApi : public IExecutionApi {
TestApiConfig config_{};
};
-static void SetupConfig(std::filesystem::path const& ws) {
+[[nodiscard]] auto SetupConfig(std::filesystem::path const& ws)
+ -> RepositoryConfig {
auto info = RepositoryConfig::RepositoryInfo{FileRoot{ws}};
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo("", std::move(info));
+ RepositoryConfig repo_config{};
+ repo_config.SetInfo("", std::move(info));
+ return repo_config;
}
[[nodiscard]] static auto CreateTest(gsl::not_null<DependencyGraph*> const& g,
std::filesystem::path const& ws)
- -> TestApiConfig {
+ -> std::pair<TestApiConfig, RepositoryConfig> {
using path = std::filesystem::path;
- SetupConfig(ws);
auto const local_cpp_desc = ArtifactDescription{path{"local.cpp"}, ""};
auto const known_cpp_desc = ArtifactDescription{
@@ -243,14 +245,14 @@ static void SetupConfig(std::filesystem::path const& ws) {
config.response.cached = true;
config.response.exit_code = 0;
- return config;
+ return std::make_pair(config, SetupConfig(ws));
}
TEST_CASE("Executor: Process artifact", "[executor]") {
std::filesystem::path workspace_path{
"test/buildtool/execution_engine/executor"};
DependencyGraph g;
- auto config = CreateTest(&g, workspace_path);
+ auto [config, repo_config] = CreateTest(&g, workspace_path);
auto const local_cpp_desc =
ArtifactFactory::DescribeLocalArtifact("local.cpp", "");
@@ -262,7 +264,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
SECTION("Processing succeeds for valid config") {
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -272,7 +274,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
config.artifacts["local.cpp"].uploads = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(not runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -282,7 +284,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
config.artifacts["known.cpp"].available = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(not runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -294,7 +296,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
"test/buildtool/execution_engine/executor"};
DependencyGraph g;
- auto config = CreateTest(&g, workspace_path);
+ auto [config, repo_config] = CreateTest(&g, workspace_path);
auto const local_cpp_desc =
ArtifactFactory::DescribeLocalArtifact("local.cpp", "");
@@ -315,7 +317,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
SECTION("Processing succeeds for valid config") {
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -328,7 +330,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.response.cached = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -341,7 +343,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.artifacts["output2.exe"].available = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -357,7 +359,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.execution.failed = true;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -370,7 +372,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.response.exit_code = 1;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -386,7 +388,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.execution.outputs = {"output1.exe" /*, "output2.exe"*/};
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{api.get(), api.get(), {}};
+ Executor runner{&repo_config, api.get(), api.get(), {}};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp
index bd02e0fb..85b19911 100755
--- a/test/buildtool/execution_engine/executor/executor_api.test.hpp
+++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp
@@ -21,6 +21,7 @@
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/artifact_description.hpp"
#include "src/buildtool/common/artifact_factory.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/execution_engine/dag/dag.hpp"
@@ -30,14 +31,16 @@
using ApiFactory = std::function<IExecutionApi::Ptr()>;
-static inline void SetupConfig() {
+static inline void SetupConfig(RepositoryConfig* repo_config) {
auto info = RepositoryConfig::RepositoryInfo{FileRoot{
std::filesystem::path{"test/buildtool/execution_engine/executor"}}};
- RepositoryConfig::Instance().SetInfo("", std::move(info));
+ repo_config->Reset();
+ repo_config->SetInfo("", std::move(info));
}
-static inline void RunBlobUpload(ApiFactory const& factory) {
- SetupConfig();
+static inline void RunBlobUpload(RepositoryConfig* repo_config,
+ ApiFactory const& factory) {
+ SetupConfig(repo_config);
auto api = factory();
std::string const blob = "test";
CHECK(api->Upload(BlobContainer{{BazelBlob{
@@ -77,12 +80,13 @@ template <class Executor>
return tree_artifact->Content().Info();
}
-static inline void RunHelloWorldCompilation(ApiFactory const& factory,
+static inline void RunHelloWorldCompilation(RepositoryConfig* repo_config,
+ ApiFactory const& factory,
bool is_hermetic = true,
int expected_queued = 0,
int expected_cached = 0) {
using path = std::filesystem::path;
- SetupConfig();
+ SetupConfig(repo_config);
auto const main_cpp_desc =
ArtifactDescription{path{"data/hello_world/main.cpp"}, ""};
auto const& main_cpp_id = main_cpp_desc.Id();
@@ -103,8 +107,10 @@ static inline void RunHelloWorldCompilation(ApiFactory const& factory,
CHECK(g.ArtifactNodeWithId(exec_id)->HasBuilderAction());
auto api = factory();
- Executor runner{
- api.get(), api.get(), RemoteExecutionConfig::PlatformProperties()};
+ Executor runner{repo_config,
+ api.get(),
+ api.get(),
+ RemoteExecutionConfig::PlatformProperties()};
// upload local artifacts
auto const* main_cpp_node = g.ArtifactNodeWithId(main_cpp_id);
@@ -132,13 +138,14 @@ static inline void RunHelloWorldCompilation(ApiFactory const& factory,
}
}
-static inline void RunGreeterCompilation(ApiFactory const& factory,
+static inline void RunGreeterCompilation(RepositoryConfig* repo_config,
+ ApiFactory const& factory,
std::string const& greetcpp,
bool is_hermetic = true,
int expected_queued = 0,
int expected_cached = 0) {
using path = std::filesystem::path;
- SetupConfig();
+ SetupConfig(repo_config);
auto const greet_hpp_desc =
ArtifactDescription{path{"data/greeter/greet.hpp"}, ""};
auto const& greet_hpp_id = greet_hpp_desc.Id();
@@ -206,8 +213,10 @@ static inline void RunGreeterCompilation(ApiFactory const& factory,
CHECK(g.Add({compile_greet_desc, make_lib_desc, make_exe_desc}));
auto api = factory();
- Executor runner{
- api.get(), api.get(), RemoteExecutionConfig::PlatformProperties()};
+ Executor runner{repo_config,
+ api.get(),
+ api.get(),
+ RemoteExecutionConfig::PlatformProperties()};
// upload local artifacts
for (auto const& id : {greet_hpp_id, greet_cpp_id, main_cpp_id}) {
@@ -241,52 +250,65 @@ static inline void RunGreeterCompilation(ApiFactory const& factory,
}
}
-[[maybe_unused]] static void TestBlobUpload(ApiFactory const& factory) {
- SetupConfig();
+[[maybe_unused]] static void TestBlobUpload(RepositoryConfig* repo_config,
+ ApiFactory const& factory) {
+ SetupConfig(repo_config);
// NOLINTNEXTLINE
- RunBlobUpload(factory);
+ RunBlobUpload(repo_config, factory);
}
[[maybe_unused]] static void TestHelloWorldCompilation(
+ RepositoryConfig* repo_config,
ApiFactory const& factory,
bool is_hermetic = true) {
- SetupConfig();
+ SetupConfig(repo_config);
// expecting 1 action queued, 0 results from cache
// NOLINTNEXTLINE
- RunHelloWorldCompilation(factory, is_hermetic, 1, 0);
+ RunHelloWorldCompilation(repo_config, factory, is_hermetic, 1, 0);
SECTION("Running same compilation again") {
// expecting 2 actions queued, 1 result from cache
// NOLINTNEXTLINE
- RunHelloWorldCompilation(factory, is_hermetic, 2, 1);
+ RunHelloWorldCompilation(repo_config, factory, is_hermetic, 2, 1);
}
}
-[[maybe_unused]] static void TestGreeterCompilation(ApiFactory const& factory,
- bool is_hermetic = true) {
- SetupConfig();
+[[maybe_unused]] static void TestGreeterCompilation(
+ RepositoryConfig* repo_config,
+ ApiFactory const& factory,
+ bool is_hermetic = true) {
+ SetupConfig(repo_config);
// expecting 3 action queued, 0 results from cache
// NOLINTNEXTLINE
- RunGreeterCompilation(factory, "greet.cpp", is_hermetic, 3, 0);
+ RunGreeterCompilation(repo_config, factory, "greet.cpp", is_hermetic, 3, 0);
SECTION("Running same compilation again") {
// expecting 6 actions queued, 3 results from cache
- // NOLINTNEXTLINE
- RunGreeterCompilation(factory, "greet.cpp", is_hermetic, 6, 3);
+ RunGreeterCompilation(repo_config,
+ factory,
+ "greet.cpp",
+ is_hermetic,
+ 6, // NOLINT
+ 3);
}
SECTION("Running modified compilation") {
// expecting 6 actions queued, 2 results from cache
- // NOLINTNEXTLINE
- RunGreeterCompilation(factory, "greet_mod.cpp", is_hermetic, 6, 2);
+ RunGreeterCompilation(repo_config,
+ factory,
+ "greet_mod.cpp",
+ is_hermetic,
+ 6, // NOLINT
+ 2);
}
}
-static inline void TestUploadAndDownloadTrees(ApiFactory const& factory,
+static inline void TestUploadAndDownloadTrees(RepositoryConfig* repo_config,
+ ApiFactory const& factory,
bool /*is_hermetic*/ = true,
int /*expected_queued*/ = 0,
int /*expected_cached*/ = 0) {
- SetupConfig();
+ SetupConfig(repo_config);
auto tmpdir = GetTestDir();
auto foo = std::string{"foo"};
@@ -314,8 +336,10 @@ static inline void TestUploadAndDownloadTrees(ApiFactory const& factory,
auto foo_id = g.AddArtifact(foo_desc);
auto bar_id = g.AddArtifact(bar_desc);
- Executor runner{
- api.get(), api.get(), RemoteExecutionConfig::PlatformProperties()};
+ Executor runner{repo_config,
+ api.get(),
+ api.get(),
+ RemoteExecutionConfig::PlatformProperties()};
REQUIRE(runner.Process(g.ArtifactNodeWithId(foo_id)));
REQUIRE(runner.Process(g.ArtifactNodeWithId(bar_id)));
@@ -415,11 +439,12 @@ static inline void TestUploadAndDownloadTrees(ApiFactory const& factory,
}
}
-static inline void TestRetrieveOutputDirectories(ApiFactory const& factory,
+static inline void TestRetrieveOutputDirectories(RepositoryConfig* repo_config,
+ ApiFactory const& factory,
bool /*is_hermetic*/ = true,
int /*expected_queued*/ = 0,
int /*expected_cached*/ = 0) {
- SetupConfig();
+ SetupConfig(repo_config);
auto tmpdir = GetTestDir();
auto const make_tree_id = std::string{"make_tree"};
@@ -457,8 +482,10 @@ static inline void TestRetrieveOutputDirectories(ApiFactory const& factory,
// run action
auto api = factory();
- Executor runner{
- api.get(), api.get(), RemoteExecutionConfig::PlatformProperties()};
+ Executor runner{repo_config,
+ api.get(),
+ api.get(),
+ RemoteExecutionConfig::PlatformProperties()};
REQUIRE(runner.Process(action));
// read output
@@ -502,8 +529,10 @@ static inline void TestRetrieveOutputDirectories(ApiFactory const& factory,
// run action
auto api = factory();
- Executor runner{
- api.get(), api.get(), RemoteExecutionConfig::PlatformProperties()};
+ Executor runner{repo_config,
+ api.get(),
+ api.get(),
+ RemoteExecutionConfig::PlatformProperties()};
REQUIRE(runner.Process(action));
// read output
@@ -563,8 +592,10 @@ static inline void TestRetrieveOutputDirectories(ApiFactory const& factory,
// run action
auto api = factory();
- Executor runner{
- api.get(), api.get(), RemoteExecutionConfig::PlatformProperties()};
+ Executor runner{repo_config,
+ api.get(),
+ api.get(),
+ RemoteExecutionConfig::PlatformProperties()};
REQUIRE(runner.Process(action));
// read output
@@ -629,7 +660,8 @@ static inline void TestRetrieveOutputDirectories(ApiFactory const& factory,
// run action
auto api = factory();
- Executor runner{api.get(),
+ Executor runner{repo_config,
+ api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties()};
CHECK_FALSE(runner.Process(action));
@@ -649,7 +681,8 @@ static inline void TestRetrieveOutputDirectories(ApiFactory const& factory,
// run action
auto api = factory();
- Executor runner{api.get(),
+ Executor runner{repo_config,
+ api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties()};
CHECK_FALSE(runner.Process(action));
diff --git a/test/buildtool/execution_engine/executor/executor_api_local.test.cpp b/test/buildtool/execution_engine/executor/executor_api_local.test.cpp
index 3f5f2ac9..f196e98b 100755
--- a/test/buildtool/execution_engine/executor/executor_api_local.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor_api_local.test.cpp
@@ -13,6 +13,7 @@
// limitations under the License.
#include "catch2/catch_test_macros.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
@@ -22,29 +23,39 @@
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Upload blob",
"[executor]") {
- TestBlobUpload([&] { return std::make_unique<LocalApi>(); });
+ RepositoryConfig repo_config{};
+ TestBlobUpload(&repo_config,
+ [&] { return std::make_unique<LocalApi>(&repo_config); });
}
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Compile hello world",
"[executor]") {
- TestHelloWorldCompilation([&] { return std::make_unique<LocalApi>(); });
+ RepositoryConfig repo_config{};
+ TestHelloWorldCompilation(
+ &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
}
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Compile greeter",
"[executor]") {
- TestGreeterCompilation([&] { return std::make_unique<LocalApi>(); });
+ RepositoryConfig repo_config{};
+ TestGreeterCompilation(
+ &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
}
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Upload and download trees",
"[executor]") {
- TestUploadAndDownloadTrees([&] { return std::make_unique<LocalApi>(); });
+ RepositoryConfig repo_config{};
+ TestUploadAndDownloadTrees(
+ &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
}
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Retrieve output directories",
"[executor]") {
- TestRetrieveOutputDirectories([&] { return std::make_unique<LocalApi>(); });
+ RepositoryConfig repo_config{};
+ TestRetrieveOutputDirectories(
+ &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
}
diff --git a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
index fb34749f..4df56ec2 100755
--- a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
@@ -13,28 +13,32 @@
// limitations under the License.
#include "catch2/catch_test_macros.hpp"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
#include "test/buildtool/execution_engine/executor/executor_api.test.hpp"
TEST_CASE("Executor<BazelApi>: Upload blob", "[executor]") {
+ RepositoryConfig repo_config{};
ExecutionConfiguration config;
auto const& info = RemoteExecutionConfig::RemoteAddress();
- TestBlobUpload([&] {
+ TestBlobUpload(&repo_config, [&] {
return BazelApi::Ptr{
new BazelApi{"remote-execution", info->host, info->port, config}};
});
}
TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") {
+ RepositoryConfig repo_config{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
auto const& info = RemoteExecutionConfig::RemoteAddress();
TestHelloWorldCompilation(
+ &repo_config,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
@@ -43,12 +47,14 @@ TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") {
}
TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") {
+ RepositoryConfig repo_config{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
auto const& info = RemoteExecutionConfig::RemoteAddress();
TestGreeterCompilation(
+ &repo_config,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
@@ -57,12 +63,14 @@ TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") {
}
TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") {
+ RepositoryConfig repo_config{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
auto const& info = RemoteExecutionConfig::RemoteAddress();
TestUploadAndDownloadTrees(
+ &repo_config,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
@@ -71,12 +79,14 @@ TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") {
}
TEST_CASE("Executor<BazelApi>: Retrieve output directories", "[executor]") {
+ RepositoryConfig repo_config{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
auto const& info = RemoteExecutionConfig::RemoteAddress();
TestRetrieveOutputDirectories(
+ &repo_config,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
diff --git a/test/buildtool/graph_traverser/graph_traverser.test.hpp b/test/buildtool/graph_traverser/graph_traverser.test.hpp
index 84b348e4..a7eeb1e0 100644
--- a/test/buildtool/graph_traverser/graph_traverser.test.hpp
+++ b/test/buildtool/graph_traverser/graph_traverser.test.hpp
@@ -80,6 +80,8 @@ class TestProject {
return GenerateFromEntryPoints(*entry_points_json);
}
+ auto GetRepoConfig() -> RepositoryConfig* { return &repo_config_; }
+
private:
static inline std::filesystem::path const kOutputDirPrefix =
FileSystemManager::GetCurrentDirectory() / "./tmp-";
@@ -90,11 +92,11 @@ class TestProject {
"_entry_points";
std::string example_name_{};
std::filesystem::path root_dir_{};
+ RepositoryConfig repo_config_{};
void SetupConfig() {
auto info = RepositoryConfig::RepositoryInfo{FileRoot{root_dir_}};
- RepositoryConfig::Instance().Reset();
- RepositoryConfig::Instance().SetInfo("", std::move(info));
+ repo_config_.SetInfo("", std::move(info));
}
auto GenerateFromEntryPoints(nlohmann::json const& entry_points)
@@ -127,7 +129,7 @@ class TestProject {
TestProject p("hello_world_copy_message");
auto const clargs = p.CmdLineArgs();
- GraphTraverser const gt{clargs.gtargs};
+ GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -146,7 +148,7 @@ class TestProject {
SECTION("Executable is retrieved as executable") {
auto const clargs_exec = p.CmdLineArgs("_entry_points_get_executable");
- GraphTraverser const gt_get_exec{clargs_exec.gtargs};
+ GraphTraverser const gt_get_exec{clargs_exec.gtargs, p.GetRepoConfig()};
auto const exec_result = gt_get_exec.BuildAndStage(
clargs_exec.graph_description, clargs_exec.artifacts);
@@ -170,7 +172,7 @@ class TestProject {
TestProject p("copy_local_file");
auto const clargs = p.CmdLineArgs();
- GraphTraverser const gt{clargs.gtargs};
+ GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -189,7 +191,7 @@ class TestProject {
TestProject p("sequence_printer_build_library_only");
auto const clargs = p.CmdLineArgs();
- GraphTraverser const gt{clargs.gtargs};
+ GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -198,7 +200,8 @@ class TestProject {
CHECK(FileSystemManager::IsFile(result->output_paths.at(0)));
auto const clargs_full_build = p.CmdLineArgs("_entry_points_full_build");
- GraphTraverser const gt_full_build{clargs_full_build.gtargs};
+ GraphTraverser const gt_full_build{clargs_full_build.gtargs,
+ p.GetRepoConfig()};
auto const full_build_result = gt_full_build.BuildAndStage(
clargs_full_build.graph_description, clargs_full_build.artifacts);
@@ -221,7 +224,8 @@ class TestProject {
auto const clargs_update_cpp =
full_hello_world.CmdLineArgs("_entry_points_upload_source");
- GraphTraverser const gt_upload{clargs_update_cpp.gtargs};
+ GraphTraverser const gt_upload{clargs_update_cpp.gtargs,
+ full_hello_world.GetRepoConfig()};
auto const cpp_result = gt_upload.BuildAndStage(
clargs_update_cpp.graph_description, clargs_update_cpp.artifacts);
@@ -237,7 +241,7 @@ class TestProject {
TestProject hello_world_known_cpp("hello_world_known_source");
auto const clargs = hello_world_known_cpp.CmdLineArgs();
- GraphTraverser const gt{clargs.gtargs};
+ GraphTraverser const gt{clargs.gtargs, full_hello_world.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -258,7 +262,7 @@ static void TestBlobsUploadedAndUsed(bool is_hermetic = true) {
TestProject p("use_uploaded_blobs");
auto const clargs = p.CmdLineArgs();
- GraphTraverser gt{clargs.gtargs};
+ GraphTraverser gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -284,7 +288,7 @@ static void TestEnvironmentVariablesSetAndUsed(bool is_hermetic = true) {
TestProject p("use_env_variables");
auto const clargs = p.CmdLineArgs();
- GraphTraverser gt{clargs.gtargs};
+ GraphTraverser gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -310,7 +314,7 @@ static void TestTreesUsed(bool is_hermetic = true) {
TestProject p("use_trees");
auto const clargs = p.CmdLineArgs();
- GraphTraverser gt{clargs.gtargs};
+ GraphTraverser gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -336,7 +340,7 @@ static void TestNestedTreesUsed(bool is_hermetic = true) {
TestProject p("use_nested_trees");
auto const clargs = p.CmdLineArgs();
- GraphTraverser gt{clargs.gtargs};
+ GraphTraverser gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -363,7 +367,7 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
{
auto clargs = p.CmdLineArgs("_entry_points_ctimes");
- GraphTraverser const gt{clargs.gtargs};
+ GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig()};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -377,7 +381,7 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
// make_exe[flaky]->make_output[miss]
auto clargs_output = p.CmdLineArgs();
clargs_output.gtargs.rebuild = RebuildArguments{};
- GraphTraverser const gt_output{clargs_output.gtargs};
+ GraphTraverser const gt_output{clargs_output.gtargs, p.GetRepoConfig()};
REQUIRE(gt_output.BuildAndStage(clargs_output.graph_description,
clargs_output.artifacts));
CHECK(Statistics::Instance().ActionsFlakyCounter() == 1);
@@ -388,7 +392,7 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
// make_exe[flaky]->make_output[miss]->strip_time [miss]
auto clargs_stripped = p.CmdLineArgs("_entry_points_stripped");
clargs_stripped.gtargs.rebuild = RebuildArguments{};
- GraphTraverser const gt_stripped{clargs_stripped.gtargs};
+ GraphTraverser const gt_stripped{clargs_stripped.gtargs, p.GetRepoConfig()};
REQUIRE(gt_stripped.BuildAndStage(clargs_stripped.graph_description,
clargs_stripped.artifacts));
CHECK(Statistics::Instance().ActionsFlakyCounter() == 1);
@@ -399,7 +403,7 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
// make_exe[flaky]->make_output[miss]->strip_time[miss]->list_ctimes [flaky]
auto clargs_ctimes = p.CmdLineArgs("_entry_points_ctimes");
clargs_ctimes.gtargs.rebuild = RebuildArguments{};
- GraphTraverser const gt_ctimes{clargs_ctimes.gtargs};
+ GraphTraverser const gt_ctimes{clargs_ctimes.gtargs, p.GetRepoConfig()};
REQUIRE(gt_ctimes.BuildAndStage(clargs_ctimes.graph_description,
clargs_ctimes.artifacts));
CHECK(Statistics::Instance().ActionsFlakyCounter() == 2);