diff options
11 files changed, 233 insertions, 46 deletions
diff --git a/test/buildtool/graph_traverser/TARGETS b/test/buildtool/graph_traverser/TARGETS index f146559f..cf47ff26 100644 --- a/test/buildtool/graph_traverser/TARGETS +++ b/test/buildtool/graph_traverser/TARGETS @@ -39,41 +39,7 @@ } , "test_data": { "type": ["@", "rules", "data", "staged"] - , "srcs": - [ "data/copy_local_file/_entry_points" - , "data/copy_local_file/copy_me.hpp" - , "data/copy_local_file/graph_description" - , "data/flaky_hello_world/_entry_points" - , "data/flaky_hello_world/_entry_points_ctimes" - , "data/flaky_hello_world/_entry_points_stripped" - , "data/flaky_hello_world/graph_description" - , "data/flaky_hello_world/hello_world.cpp" - , "data/hello_world_copy_message/_entry_points" - , "data/hello_world_copy_message/_entry_points_get_executable" - , "data/hello_world_copy_message/_entry_points_upload_source" - , "data/hello_world_copy_message/graph_description" - , "data/hello_world_copy_message/hello_world.cpp" - , "data/hello_world_known_source/_entry_points" - , "data/hello_world_known_source/graph_description" - , "data/sequence_printer_build_library_only/_entry_points" - , "data/sequence_printer_build_library_only/_entry_points_full_build" - , "data/sequence_printer_build_library_only/graph_description" - , "data/sequence_printer_build_library_only/main.cpp" - , "data/sequence_printer_build_library_only/printer/printer.hpp" - , "data/sequence_printer_build_library_only/sequences/fibonacci.cpp" - , "data/sequence_printer_build_library_only/sequences/fibonacci.hpp" - , "data/sequence_printer_build_library_only/sequences/random_dna_sequence.cpp" - , "data/sequence_printer_build_library_only/sequences/random_dna_sequence.hpp" - , "data/sequence_printer_build_library_only/sequences/sequence.hpp" - , "data/use_env_variables/_entry_points" - , "data/use_env_variables/graph_description" - , "data/use_nested_trees/_entry_points" - , "data/use_nested_trees/graph_description" - , "data/use_trees/_entry_points" - , "data/use_trees/graph_description" - , "data/use_uploaded_blobs/_entry_points" - , "data/use_uploaded_blobs/graph_description" - ] + , "srcs": [["TREE", "test/buildtool/graph_traverser", "data"]] , "stage": ["test", "buildtool", "graph_traverser"] } , "TESTS": 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 new file mode 100644 index 00000000..f0d77b13 --- /dev/null +++ b/test/buildtool/graph_traverser/data/hello_world_known_source/graph_description_compatible @@ -0,0 +1,46 @@ +{ + "actions": { + "make_exe": { + "output": [ + "hello_world" + ], + "command": [ + "c++", "hello_world.cpp", "-o", "hello_world" + ], + "input": { + "hello_world.cpp": { + "type": "KNOWN", + "data": { + "id": "f94d12e55ec4661e3a6eda4790c8e1996382d2f6d45fecf3cabddd2b1eee7398", + "size": 83, + "file_type": "f" + } + } + }, + "env": { + "PATH": "/bin:/usr/bin" + } + }, + "make_output": { + "output": [ + "greeting_output" + ], + "command": [ + "/bin/sh", + "-c", + "set -e\n./hello_world > greeting_output\nls -alR\n" + ], + "input": { + "hello_world": { + "type": "ACTION", + "data": { + "id": "make_exe", + "path": "hello_world" + } + } + } + } + }, + "blobs": [], + "trees": {} +} diff --git a/test/buildtool/graph_traverser/data/use_nested_trees/graph_description b/test/buildtool/graph_traverser/data/use_nested_trees/graph_description index 201dd5b0..e06e7596 100644 --- a/test/buildtool/graph_traverser/data/use_nested_trees/graph_description +++ b/test/buildtool/graph_traverser/data/use_nested_trees/graph_description @@ -1,7 +1,7 @@ { "blobs": ["test to check if blobs are uploaded", "this"], "trees": { - "4d8756372185a2f0c7a1c63ae4aec5080d5abb0e": { + "tree-0": { "subject": { "type": "KNOWN", "data": { @@ -11,11 +11,11 @@ } } }, - "a00e8ce5eec43c5d77b54d0df6016df943ed05da": { + "tree-1": { "nested": { "type": "TREE", "data": { - "id": "4d8756372185a2f0c7a1c63ae4aec5080d5abb0e" + "id": "tree-0" } } } @@ -26,7 +26,7 @@ "main": { "type": "TREE", "data": { - "id": "a00e8ce5eec43c5d77b54d0df6016df943ed05da" + "id": "tree-1" } }, "thing": { diff --git a/test/buildtool/graph_traverser/data/use_nested_trees/graph_description_compatible b/test/buildtool/graph_traverser/data/use_nested_trees/graph_description_compatible new file mode 100644 index 00000000..b71367e9 --- /dev/null +++ b/test/buildtool/graph_traverser/data/use_nested_trees/graph_description_compatible @@ -0,0 +1,51 @@ +{ + "blobs": ["test to check if blobs are uploaded", "this"], + "trees": { + "tree-0": { + "subject": { + "type": "KNOWN", + "data": { + "id": "1eb79602411ef02cf6fe117897015fff89f80face4eccd50425c45149b148408", + "size": 4, + "file_type": "f" + } + } + }, + "tree-1": { + "nested": { + "type": "TREE", + "data": { + "id": "tree-0" + } + } + } + }, + "actions": { + "write_test": { + "input": { + "main": { + "type": "TREE", + "data": { + "id": "tree-1" + } + }, + "thing": { + "type": "KNOWN", + "data": { + "id": "0bbd636ca17d06a5b630fe3f19844192f57fb70ae9b24686cc8a2fa7e48c9b77", + "size": 35, + "file_type": "f" + } + } + }, + "output": [ + "statement" + ], + "command": [ + "/bin/sh", + "-c", + "set -e\necho -n \"$(cat main/nested/subject) is a $(cat thing)\" > statement" + ] + } + } +} diff --git a/test/buildtool/graph_traverser/data/use_trees/graph_description b/test/buildtool/graph_traverser/data/use_trees/graph_description index 26e43ade..ff405309 100644 --- a/test/buildtool/graph_traverser/data/use_trees/graph_description +++ b/test/buildtool/graph_traverser/data/use_trees/graph_description @@ -1,7 +1,7 @@ { "blobs": ["test to check if blobs are uploaded", "this"], "trees": { - "a6a2c1940ec94d9b93b86cf2c73d434402eb36ae": { + "tree-0": { "subject": { "type": "KNOWN", "data": { @@ -19,7 +19,7 @@ } } }, - "4a331831df3699e3e37ea31ac15c3b9cc318e06d": { + "tree-1": { "test_data": { "type": "ACTION", "data": { @@ -35,7 +35,7 @@ ".": { "type": "TREE", "data": { - "id": "a6a2c1940ec94d9b93b86cf2c73d434402eb36ae" + "id": "tree-0" } } }, @@ -53,7 +53,7 @@ "data": { "type": "TREE", "data": { - "id": "4a331831df3699e3e37ea31ac15c3b9cc318e06d" + "id": "tree-1" } } }, diff --git a/test/buildtool/graph_traverser/data/use_trees/graph_description_compatible b/test/buildtool/graph_traverser/data/use_trees/graph_description_compatible new file mode 100644 index 00000000..6ca051da --- /dev/null +++ b/test/buildtool/graph_traverser/data/use_trees/graph_description_compatible @@ -0,0 +1,70 @@ +{ + "blobs": ["test to check if blobs are uploaded", "this"], + "trees": { + "tree-0": { + "subject": { + "type": "KNOWN", + "data": { + "id": "1eb79602411ef02cf6fe117897015fff89f80face4eccd50425c45149b148408", + "size": 4, + "file_type": "f" + } + }, + "thing": { + "type": "KNOWN", + "data": { + "id": "0bbd636ca17d06a5b630fe3f19844192f57fb70ae9b24686cc8a2fa7e48c9b77", + "size": 35, + "file_type": "f" + } + } + }, + "tree-1": { + "test_data": { + "type": "ACTION", + "data": { + "id": "write_test", + "path": "statement" + } + } + } + }, + "actions": { + "write_test": { + "input": { + ".": { + "type": "TREE", + "data": { + "id": "tree-0" + } + } + }, + "output": [ + "statement" + ], + "command": [ + "/bin/sh", + "-c", + "set -e\necho -n \"$(cat subject) is a $(cat thing)\" > statement" + ] + }, + "read_test": { + "input": { + "data": { + "type": "TREE", + "data": { + "id": "tree-1" + } + } + }, + "output": [ + "statement" + ], + "command": [ + "/bin/sh", + "-c", + "cat data/test_data > statement" + ] + } + } +} diff --git a/test/buildtool/graph_traverser/data/use_uploaded_blobs/graph_description_compatible b/test/buildtool/graph_traverser/data/use_uploaded_blobs/graph_description_compatible new file mode 100644 index 00000000..977a0472 --- /dev/null +++ b/test/buildtool/graph_traverser/data/use_uploaded_blobs/graph_description_compatible @@ -0,0 +1,34 @@ +{ + "blobs": ["test to check if blobs are uploaded", "this"], + "trees": {}, + "actions": { + "write_test": { + "input": { + "subject": { + "type": "KNOWN", + "data": { + "id": "1eb79602411ef02cf6fe117897015fff89f80face4eccd50425c45149b148408", + "size": 4, + "file_type": "f" + } + }, + "thing": { + "type": "KNOWN", + "data": { + "id": "0bbd636ca17d06a5b630fe3f19844192f57fb70ae9b24686cc8a2fa7e48c9b77", + "size": 35, + "file_type": "f" + } + } + }, + "output": [ + "statement" + ], + "command": [ + "/bin/sh", + "-c", + "set -e\necho -n \"$(cat subject) is a $(cat thing)\" > statement" + ] + } + } +} diff --git a/test/buildtool/graph_traverser/graph_traverser.test.hpp b/test/buildtool/graph_traverser/graph_traverser.test.hpp index 634c37e1..b1041d73 100644 --- a/test/buildtool/graph_traverser/graph_traverser.test.hpp +++ b/test/buildtool/graph_traverser/graph_traverser.test.hpp @@ -95,7 +95,14 @@ class TestProject { CommandLineArguments clargs{gtargs}; clargs.artifacts = entry_points; - clargs.graph_description = root_dir_ / "graph_description"; + auto const comp_graph = root_dir_ / "graph_description_compatible"; + if (Compatibility::IsCompatible() and + std::filesystem::exists(comp_graph)) { + clargs.graph_description = comp_graph; + } + else { + clargs.graph_description = root_dir_ / "graph_description"; + } clargs.gtargs.jobs = std::max(1U, std::thread::hardware_concurrency()); clargs.gtargs.stage = StageArguments{ kOutputDirPrefix / (example_name_ + std::to_string(id++))}; @@ -233,7 +240,6 @@ class TestProject { CHECK(Statistics::Instance().ActionsQueuedCounter() == 0); CHECK(Statistics::Instance().ActionsCachedCounter() == 0); } - TestProject hello_world_known_cpp("hello_world_known_source", run_local); auto const clargs = hello_world_known_cpp.CmdLineArgs(); diff --git a/test/utils/TARGETS b/test/utils/TARGETS index 4ce38cd5..a0d637b1 100644 --- a/test/utils/TARGETS +++ b/test/utils/TARGETS @@ -26,7 +26,7 @@ { "type": ["@", "rules", "CC", "library"] , "name": ["test_env"] , "hdrs": ["test_env.hpp"] - , "deps": ["log_config"] + , "deps": ["log_config", ["src/buildtool/compatibility", "compatibility"]] , "stage": ["test", "utils"] } , "local_hermeticity": @@ -48,6 +48,7 @@ , "deps": [ ["@", "catch2", "", "catch2"] , ["src/buildtool/execution_api/remote", "config"] + , ["src/buildtool/compatibility", "compatibility"] , "log_config" , "test_env" ] diff --git a/test/utils/remote_execution/main-remote-execution.cpp b/test/utils/remote_execution/main-remote-execution.cpp index 3f435dcc..4db1d690 100755..100644 --- a/test/utils/remote_execution/main-remote-execution.cpp +++ b/test/utils/remote_execution/main-remote-execution.cpp @@ -6,6 +6,7 @@ #include <thread> #include "catch2/catch.hpp" +#include "src/buildtool/compatibility/compatibility.hpp" #include "src/buildtool/execution_api/remote/config.hpp" #include "test/utils/logging/log_config.hpp" #include "test/utils/test_env.hpp" @@ -21,6 +22,10 @@ void wait_for_grpc_to_shutdown() { /// environment variable is malformed, we write a message and stop execution. /// \returns true If remote execution was successfully configured. [[nodiscard]] auto ConfigureRemoteExecution() -> bool { + ReadCompatibilityFromEnv(); + if (Compatibility::IsCompatible()) { + HashGenerator::SetHashGenerator(HashGenerator::HashType::SHA256); + } auto address = ReadRemoteAddressFromEnv(); auto& config = RemoteExecutionConfig::Instance(); if (address and not config.SetAddress(*address)) { diff --git a/test/utils/test_env.hpp b/test/utils/test_env.hpp index 3bc49901..d4f18994 100644 --- a/test/utils/test_env.hpp +++ b/test/utils/test_env.hpp @@ -7,6 +7,7 @@ #include <sstream> #include <string> +#include "src/buildtool/compatibility/compatibility.hpp" #include "test/utils/logging/log_config.hpp" [[nodiscard]] static inline auto ReadPlatformPropertiesFromEnv() @@ -33,6 +34,13 @@ return properties; } +static inline void ReadCompatibilityFromEnv() { + auto* compatible = std::getenv("COMPATIBLE"); + if (compatible != nullptr) { + Compatibility::SetCompatible(); + } +} + [[nodiscard]] static inline auto ReadRemoteAddressFromEnv() -> std::optional<std::string> { auto* execution_address = std::getenv("REMOTE_EXECUTION_ADDRESS"); |