diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-03-06 17:17:16 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-03-11 15:59:05 +0100 |
commit | b885deebf9fc02b9f1e849d91de93fadcfb71a73 (patch) | |
tree | a26b4f9ad05e479b51b97a1a4c489525243c241a /test/buildtool/build_engine/target_map/target_map.test.cpp | |
parent | 1bba42d5168a13dbebda8820fc5e28df1d401669 (diff) | |
download | justbuild-b885deebf9fc02b9f1e849d91de93fadcfb71a73.tar.gz |
just analyse: Use explicit target cache instance
The serve endpoint always has to access the correctly sharded
target cache, including during analysis. For this purpose, the
target cache instance interrogated during analysis has to be
explicitly provided.
Diffstat (limited to 'test/buildtool/build_engine/target_map/target_map.test.cpp')
-rw-r--r-- | test/buildtool/build_engine/target_map/target_map.test.cpp | 152 |
1 files changed, 88 insertions, 64 deletions
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 14701f6c..dd7c19a9 100644 --- a/test/buildtool/build_engine/target_map/target_map.test.cpp +++ b/test/buildtool/build_engine/target_map/target_map.test.cpp @@ -25,6 +25,8 @@ #include "src/buildtool/build_engine/target_map/target_map.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/multithreading/task_system.hpp" +#include "src/buildtool/storage/storage.hpp" +#include "test/utils/hermeticity/local.hpp" namespace { @@ -64,7 +66,7 @@ auto SetupConfig() -> RepositoryConfig { } // namespace -TEST_CASE("simple targets") { +TEST_CASE_METHOD(HermeticLocalTestFixture, "simple targets", "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -82,13 +84,15 @@ TEST_CASE("simple targets") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); AnalysedTargetPtr result; bool error{false}; @@ -409,7 +413,9 @@ TEST_CASE("simple targets") { } } -TEST_CASE("configuration deduplication") { +TEST_CASE_METHOD(HermeticLocalTestFixture, + "configuration deduplication", + "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -427,13 +433,15 @@ TEST_CASE("configuration deduplication") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); std::vector<AnalysedTargetPtr> result; bool error{false}; @@ -476,7 +484,9 @@ TEST_CASE("configuration deduplication") { CHECK(analysis_result.actions.size() == 2); } -TEST_CASE("generator functions in string arguments") { +TEST_CASE_METHOD(HermeticLocalTestFixture, + "generator functions in string arguments", + "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -494,13 +504,15 @@ TEST_CASE("generator functions in string arguments") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); AnalysedTargetPtr result; bool error{false}; @@ -556,7 +568,7 @@ TEST_CASE("generator functions in string arguments") { } } -TEST_CASE("built-in rules") { +TEST_CASE_METHOD(HermeticLocalTestFixture, "built-in rules", "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -574,13 +586,15 @@ TEST_CASE("built-in rules") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); AnalysedTargetPtr result; bool error{false}; std::string error_msg; @@ -746,7 +760,7 @@ TEST_CASE("built-in rules") { } } -TEST_CASE("target reference") { +TEST_CASE_METHOD(HermeticLocalTestFixture, "target reference", "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -764,13 +778,15 @@ TEST_CASE("target reference") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); AnalysedTargetPtr result; bool error{false}; @@ -869,7 +885,7 @@ TEST_CASE("target reference") { } } -TEST_CASE("trees") { +TEST_CASE_METHOD(HermeticLocalTestFixture, "trees", "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -887,13 +903,15 @@ TEST_CASE("trees") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); AnalysedTargetPtr result; bool error{false}; @@ -956,7 +974,9 @@ TEST_CASE("trees") { } } -TEST_CASE("RESULT error reporting") { +TEST_CASE_METHOD(HermeticLocalTestFixture, + "RESULT error reporting", + "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -974,13 +994,15 @@ TEST_CASE("RESULT error reporting") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); AnalysedTargetPtr result; bool error{false}; @@ -1102,7 +1124,7 @@ TEST_CASE("RESULT error reporting") { } } -TEST_CASE("wrong arguments") { +TEST_CASE_METHOD(HermeticLocalTestFixture, "wrong arguments", "[target_map]") { auto repo_config = SetupConfig(); auto directory_entries = BuildMaps::Base::CreateDirectoryEntriesMap(&repo_config); @@ -1120,13 +1142,15 @@ TEST_CASE("wrong arguments") { BuildMaps::Target::ResultTargetMap result_map{0}; auto absent_target_map = 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, - &repo_config); + auto target_map = + BuildMaps::Target::CreateTargetMap(&source, + &targets_file_map, + &rule_map, + &directory_entries, + &absent_target_map, + &result_map, + &repo_config, + Storage::Instance().TargetCache()); AnalysedTargetPtr result; bool error{false}; |