summaryrefslogtreecommitdiff
path: root/test/buildtool/graph_traverser/graph_traverser.test.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-24 11:31:42 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-27 15:03:20 +0100
commitcf04253130030bc28866d10aa1f8fe1353643d42 (patch)
treeef7049624771866455105a8dab7b001840139701 /test/buildtool/graph_traverser/graph_traverser.test.hpp
parentbc09302c2772c979c45ecc716c36e4a70bb484ac (diff)
downloadjustbuild-cf04253130030bc28866d10aa1f8fe1353643d42.tar.gz
Refactoring RepositoryConfig
With the introduction of 'just serve', export targets can now be built also independently from one another based on their corresponding minimal repository configuration, as stored in the target cache key. In this context, this commit changes the RepositoryConfig usage from one global (static) instance to pointers passed as necessary throughout the code.
Diffstat (limited to 'test/buildtool/graph_traverser/graph_traverser.test.hpp')
-rw-r--r--test/buildtool/graph_traverser/graph_traverser.test.hpp38
1 files changed, 21 insertions, 17 deletions
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);