diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-08 11:28:13 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-16 17:51:12 +0200 |
commit | 978de9de55d9592c258052dd52dc25c788a89d78 (patch) | |
tree | dff959d84f1d95af1f0546471d3b2c7eaa47dbc2 /test/buildtool/graph_traverser/graph_traverser.test.hpp | |
parent | b4cd4d0c0d1b526eab3549c9cba12179dbba3a3f (diff) | |
download | justbuild-978de9de55d9592c258052dd52dc25c788a89d78.tar.gz |
Remove the LocalExecutionConfig singleton
...and replace it with passed instances created early via a builder
pattern.
Diffstat (limited to 'test/buildtool/graph_traverser/graph_traverser.test.hpp')
-rw-r--r-- | test/buildtool/graph_traverser/graph_traverser.test.hpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/test/buildtool/graph_traverser/graph_traverser.test.hpp b/test/buildtool/graph_traverser/graph_traverser.test.hpp index ae07d347..4d47ef39 100644 --- a/test/buildtool/graph_traverser/graph_traverser.test.hpp +++ b/test/buildtool/graph_traverser/graph_traverser.test.hpp @@ -137,7 +137,8 @@ class TestProject { } }; -inline void SetLauncher() { +[[nodiscard]] inline auto CreateLocalExecConfig() noexcept + -> LocalExecutionConfig { std::vector<std::string> launcher{"env"}; auto* env_path = std::getenv("PATH"); if (env_path != nullptr) { @@ -146,10 +147,12 @@ inline void SetLauncher() { else { launcher.emplace_back("PATH=/bin:/usr/bin"); } - if (not LocalExecutionConfig::SetLauncher(launcher)) { - Logger::Log(LogLevel::Error, "Failure setting the local launcher."); - std::exit(EXIT_FAILURE); + LocalExecutionConfig::Builder builder; + if (auto config = builder.SetLauncher(std::move(launcher)).Build()) { + return *std::move(config); } + Logger::Log(LogLevel::Error, "Failure setting the local launcher."); + std::exit(EXIT_FAILURE); } } // namespace @@ -161,13 +164,13 @@ inline void SetLauncher() { bool is_hermetic = true) { TestProject p("hello_world_copy_message"); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); auto const clargs = p.CmdLineArgs(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -199,7 +202,7 @@ inline void SetLauncher() { auto const clargs_exec = p.CmdLineArgs("_entry_points_get_executable"); ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -237,13 +240,13 @@ inline void SetLauncher() { bool is_hermetic = true) { TestProject p("copy_local_file"); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); auto const clargs = p.CmdLineArgs(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -275,13 +278,13 @@ inline void SetLauncher() { bool is_hermetic = true) { TestProject p("sequence_printer_build_library_only"); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); auto const clargs = p.CmdLineArgs(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -333,14 +336,14 @@ inline void SetLauncher() { bool is_hermetic = true) { TestProject full_hello_world("hello_world_copy_message"); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); auto const clargs_update_cpp = full_hello_world.CmdLineArgs("_entry_points_upload_source"); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, full_hello_world.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -398,12 +401,12 @@ static void TestBlobsUploadedAndUsed(StorageConfig const& storage_config, TestProject p("use_uploaded_blobs"); auto const clargs = p.CmdLineArgs(); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -444,12 +447,12 @@ static void TestEnvironmentVariablesSetAndUsed( TestProject p("use_env_variables"); auto const clargs = p.CmdLineArgs(); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -489,12 +492,12 @@ static void TestTreesUsed(StorageConfig const& storage_config, TestProject p("use_trees"); auto const clargs = p.CmdLineArgs(); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -534,12 +537,12 @@ static void TestNestedTreesUsed(StorageConfig const& storage_config, TestProject p("use_nested_trees"); auto const clargs = p.CmdLineArgs(); - SetLauncher(); + auto const local_exec_config = CreateLocalExecConfig(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; @@ -578,17 +581,17 @@ static void TestFlakyHelloWorldDetected(StorageConfig const& storage_config, bool /*is_hermetic*/ = true) { TestProject p("flaky_hello_world"); + auto const local_exec_config = CreateLocalExecConfig(); Statistics stats{}; Progress progress{}; ApiBundle const apis{&storage_config, &storage, - &LocalExecutionConfig::Instance(), + &local_exec_config, p.GetRepoConfig(), auth, RemoteExecutionConfig::RemoteAddress()}; { - SetLauncher(); auto clargs = p.CmdLineArgs("_entry_points_ctimes"); GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig(), |