summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus T. Aehlig <aehlig@linta.de>2024-02-06 21:32:29 +0100
committerKlaus T. Aehlig <aehlig@linta.de>2024-02-07 15:00:18 +0100
commit04062241e380aef238da70c4c89c552522087f94 (patch)
tree92c0f999595d96d94795056fe460456d20e56eff /test
parent37411da421974c32062a3aae4939e2e740f65081 (diff)
downloadjustbuild-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')
-rw-r--r--test/buildtool/graph_traverser/TARGETS1
-rw-r--r--test/buildtool/graph_traverser/data/flaky_hello_world/graph_description3
-rw-r--r--test/buildtool/graph_traverser/data/hello_world_copy_message/graph_description3
-rw-r--r--test/buildtool/graph_traverser/data/hello_world_known_source/graph_description3
-rw-r--r--test/buildtool/graph_traverser/data/hello_world_known_source/graph_description_compatible3
-rw-r--r--test/buildtool/graph_traverser/data/sequence_printer_build_library_only/graph_description20
-rw-r--r--test/buildtool/graph_traverser/graph_traverser.test.hpp25
-rwxr-xr-xtest/utils/remote_execution/test_runner.py7
8 files changed, 37 insertions, 28 deletions
diff --git a/test/buildtool/graph_traverser/TARGETS b/test/buildtool/graph_traverser/TARGETS
index 22a8cc79..e2da438c 100644
--- a/test/buildtool/graph_traverser/TARGETS
+++ b/test/buildtool/graph_traverser/TARGETS
@@ -5,6 +5,7 @@
, "deps":
[ ["@", "catch2", "", "catch2"]
, ["@", "src", "src/buildtool/common", "common"]
+ , ["@", "src", "src/buildtool/execution_api/local", "config"]
, ["@", "src", "src/buildtool/file_system", "file_system_manager"]
, ["@", "src", "src/buildtool/file_system", "jsonfs"]
, ["@", "src", "src/buildtool/graph_traverser", "graph_traverser"]
diff --git a/test/buildtool/graph_traverser/data/flaky_hello_world/graph_description b/test/buildtool/graph_traverser/data/flaky_hello_world/graph_description
index dba67f2f..7f45fcfb 100644
--- a/test/buildtool/graph_traverser/data/flaky_hello_world/graph_description
+++ b/test/buildtool/graph_traverser/data/flaky_hello_world/graph_description
@@ -15,9 +15,6 @@
"repository": ""
}
}
- },
- "env": {
- "PATH": "/bin:/usr/bin"
}
},
"make_output": {
diff --git a/test/buildtool/graph_traverser/data/hello_world_copy_message/graph_description b/test/buildtool/graph_traverser/data/hello_world_copy_message/graph_description
index 34d68f9e..e93b9317 100644
--- a/test/buildtool/graph_traverser/data/hello_world_copy_message/graph_description
+++ b/test/buildtool/graph_traverser/data/hello_world_copy_message/graph_description
@@ -15,9 +15,6 @@
"repository": ""
}
}
- },
- "env": {
- "PATH": "/bin:/usr/bin"
}
},
"make_output": {
diff --git a/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description b/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description
index 50db4ac8..eca7646d 100644
--- a/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description
+++ b/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description
@@ -16,9 +16,6 @@
"file_type": "f"
}
}
- },
- "env": {
- "PATH": "/bin:/usr/bin"
}
},
"make_output": {
diff --git a/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description_compatible b/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description_compatible
index dcda3cfc..59c2db43 100644
--- a/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description_compatible
+++ b/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description_compatible
@@ -16,9 +16,6 @@
"file_type": "f"
}
}
- },
- "env": {
- "PATH": "/bin:/usr/bin"
}
},
"make_output": {
diff --git a/test/buildtool/graph_traverser/data/sequence_printer_build_library_only/graph_description b/test/buildtool/graph_traverser/data/sequence_printer_build_library_only/graph_description
index 3540147c..cef0c373 100644
--- a/test/buildtool/graph_traverser/data/sequence_printer_build_library_only/graph_description
+++ b/test/buildtool/graph_traverser/data/sequence_printer_build_library_only/graph_description
@@ -31,10 +31,7 @@
],
"command": [
"c++", "-o", "obj.o", "-c", "random_dna_sequence.cpp"
- ],
- "env": {
- "PATH": "/bin:/usr/bin"
- }
+ ]
},
"sequences/fibonacci/compile": {
"input": {
@@ -65,10 +62,7 @@
],
"command": [
"c++", "-o", "obj.o", "-c", "fibonacci.cpp"
- ],
- "env": {
- "PATH": "/bin:/usr/bin"
- }
+ ]
},
"sequences/link": {
"input": {
@@ -137,10 +131,7 @@
],
"command": [
"c++", "-o", "obj.o", "-c", "main.cpp"
- ],
- "env": {
- "PATH": "/bin:/usr/bin"
- }
+ ]
},
"main/link": {
"input": {
@@ -164,10 +155,7 @@
],
"command": [
"c++", "-o", "a.out", "obj1.o", "lib1.a"
- ],
- "env": {
- "PATH": "/bin:/usr/bin"
- }
+ ]
}
}
}
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(),
diff --git a/test/utils/remote_execution/test_runner.py b/test/utils/remote_execution/test_runner.py
index 948b626e..8c22c99e 100755
--- a/test/utils/remote_execution/test_runner.py
+++ b/test/utils/remote_execution/test_runner.py
@@ -56,9 +56,16 @@ if os.path.exists(REMOTE_INFO):
print(f"Warning: removing unexpected info file {REMOTE_INFO}")
os.remove(REMOTE_INFO)
+PATH=subprocess.run(
+ ["env", "--", "sh", "-c", "echo -n $PATH"],
+ stdout=subprocess.PIPE,
+).stdout.decode('utf-8')
+
remote_cmd = [
"./bin/just",
"execute",
+ "-L",
+ json.dumps(["env", "PATH=" + PATH]),
"--info-file",
REMOTE_INFO,
"--local-build-root",