diff options
author | Klaus T. Aehlig <aehlig@linta.de> | 2024-02-06 21:32:29 +0100 |
---|---|---|
committer | Klaus T. Aehlig <aehlig@linta.de> | 2024-02-07 15:00:18 +0100 |
commit | 04062241e380aef238da70c4c89c552522087f94 (patch) | |
tree | 92c0f999595d96d94795056fe460456d20e56eff /test/buildtool/graph_traverser/graph_traverser.test.hpp | |
parent | 37411da421974c32062a3aae4939e2e740f65081 (diff) | |
download | justbuild-04062241e380aef238da70c4c89c552522087f94.tar.gz |
graph_traverser test: provide env trough launcher
... instead of hard-coding it in the example graphs. In this way,
we can honor a provided PATH.
Diffstat (limited to 'test/buildtool/graph_traverser/graph_traverser.test.hpp')
-rw-r--r-- | test/buildtool/graph_traverser/graph_traverser.test.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/buildtool/graph_traverser/graph_traverser.test.hpp b/test/buildtool/graph_traverser/graph_traverser.test.hpp index 58675f91..dda1bd2d 100644 --- a/test/buildtool/graph_traverser/graph_traverser.test.hpp +++ b/test/buildtool/graph_traverser/graph_traverser.test.hpp @@ -21,6 +21,7 @@ #include "catch2/catch_test_macros.hpp" #include "src/buildtool/common/statistics.hpp" +#include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/file_system/jsonfs.hpp" #include "src/buildtool/graph_traverser/graph_traverser.hpp" @@ -122,12 +123,28 @@ class TestProject { } }; +inline void SetLauncher() { + std::vector<std::string> launcher{"env"}; + auto* env_path = std::getenv("PATH"); + if (env_path != nullptr) { + launcher.emplace_back(std::string{"PATH="} + std::string{env_path}); + } + 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); + } +} + } // namespace [[maybe_unused]] static void TestHelloWorldCopyMessage( bool is_hermetic = true) { TestProject p("hello_world_copy_message"); + SetLauncher(); auto const clargs = p.CmdLineArgs(); GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig(), @@ -178,6 +195,7 @@ class TestProject { [[maybe_unused]] static void TestCopyLocalFile(bool is_hermetic = true) { TestProject p("copy_local_file"); + SetLauncher(); auto const clargs = p.CmdLineArgs(); GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig(), @@ -200,6 +218,7 @@ class TestProject { bool is_hermetic = true) { TestProject p("sequence_printer_build_library_only"); + SetLauncher(); auto const clargs = p.CmdLineArgs(); GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig(), @@ -238,6 +257,7 @@ class TestProject { bool is_hermetic = true) { TestProject full_hello_world("hello_world_copy_message"); + SetLauncher(); auto const clargs_update_cpp = full_hello_world.CmdLineArgs("_entry_points_upload_source"); GraphTraverser const gt_upload{clargs_update_cpp.gtargs, @@ -283,6 +303,7 @@ static void TestBlobsUploadedAndUsed(bool is_hermetic = true) { TestProject p("use_uploaded_blobs"); auto const clargs = p.CmdLineArgs(); + SetLauncher(); GraphTraverser gt{clargs.gtargs, p.GetRepoConfig(), RemoteExecutionConfig::PlatformProperties(), @@ -312,6 +333,7 @@ static void TestEnvironmentVariablesSetAndUsed(bool is_hermetic = true) { TestProject p("use_env_variables"); auto const clargs = p.CmdLineArgs(); + SetLauncher(); GraphTraverser gt{clargs.gtargs, p.GetRepoConfig(), RemoteExecutionConfig::PlatformProperties(), @@ -341,6 +363,7 @@ static void TestTreesUsed(bool is_hermetic = true) { TestProject p("use_trees"); auto const clargs = p.CmdLineArgs(); + SetLauncher(); GraphTraverser gt{clargs.gtargs, p.GetRepoConfig(), RemoteExecutionConfig::PlatformProperties(), @@ -370,6 +393,7 @@ static void TestNestedTreesUsed(bool is_hermetic = true) { TestProject p("use_nested_trees"); auto const clargs = p.CmdLineArgs(); + SetLauncher(); GraphTraverser gt{clargs.gtargs, p.GetRepoConfig(), RemoteExecutionConfig::PlatformProperties(), @@ -399,6 +423,7 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) { TestProject p("flaky_hello_world"); { + SetLauncher(); auto clargs = p.CmdLineArgs("_entry_points_ctimes"); GraphTraverser const gt{clargs.gtargs, p.GetRepoConfig(), |