summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_engine
diff options
context:
space:
mode:
Diffstat (limited to 'test/buildtool/execution_engine')
-rw-r--r--test/buildtool/execution_engine/dag/dag.test.cpp24
-rw-r--r--test/buildtool/execution_engine/executor/executor.test.cpp7
-rw-r--r--test/buildtool/execution_engine/executor/executor_api.test.hpp53
-rw-r--r--test/buildtool/execution_engine/traverser/TARGETS1
-rw-r--r--test/buildtool/execution_engine/traverser/traverser.test.cpp7
5 files changed, 57 insertions, 35 deletions
diff --git a/test/buildtool/execution_engine/dag/dag.test.cpp b/test/buildtool/execution_engine/dag/dag.test.cpp
index 508c954e..cac4b791 100644
--- a/test/buildtool/execution_engine/dag/dag.test.cpp
+++ b/test/buildtool/execution_engine/dag/dag.test.cpp
@@ -130,7 +130,8 @@ TEST_CASE("AddAction({single action, more outputs, no inputs})", "[dag]") {
TEST_CASE("AddAction({single action, single output, source file})", "[dag]") {
using path = std::filesystem::path;
std::string const action_id = "action_id";
- auto const src_description = ArtifactDescription{path{"main.cpp"}, "repo"};
+ auto const src_description =
+ ArtifactDescription::CreateLocal(path{"main.cpp"}, "repo");
auto const& src_id = src_description.Id();
DependencyGraph g;
SECTION("Input file in the same path than it is locally") {
@@ -205,13 +206,17 @@ TEST_CASE("Add executable and library", "[dag]") {
std::string const make_lib_id = "make_lib";
std::vector<std::string> const make_exec_cmd = {"build", "exec"};
std::vector<std::string> const make_lib_cmd = {"build", "lib.a"};
- auto const main_desc = ArtifactDescription{path{"main.cpp"}, ""};
+ auto const main_desc =
+ ArtifactDescription::CreateLocal(path{"main.cpp"}, "");
auto const& main_id = main_desc.Id();
- auto const lib_hpp_desc = ArtifactDescription{path{"lib/lib.hpp"}, ""};
+ auto const lib_hpp_desc =
+ ArtifactDescription::CreateLocal(path{"lib/lib.hpp"}, "");
auto const& lib_hpp_id = lib_hpp_desc.Id();
- auto const lib_cpp_desc = ArtifactDescription{path{"lib/lib.cpp"}, ""};
+ auto const lib_cpp_desc =
+ ArtifactDescription::CreateLocal(path{"lib/lib.cpp"}, "");
auto const& lib_cpp_id = lib_cpp_desc.Id();
- auto const lib_a_desc = ArtifactDescription{make_lib_id, "lib.a"};
+ auto const lib_a_desc =
+ ArtifactDescription::CreateAction(make_lib_id, "lib.a");
auto const& lib_a_id = lib_a_desc.Id();
auto const make_exec_desc =
@@ -219,7 +224,8 @@ TEST_CASE("Add executable and library", "[dag]") {
{},
Action{make_exec_id, make_exec_cmd, {}},
{{"main.cpp", main_desc}, {"lib.a", lib_a_desc}}};
- auto const& exec_out_id = ArtifactDescription{make_exec_id, "exec"}.Id();
+ auto const& exec_out_id =
+ ArtifactDescription::CreateAction(make_exec_id, "exec").Id();
auto const make_lib_desc = ActionDescription{
{"lib.a"},
@@ -293,8 +299,10 @@ TEST_CASE("AddAction(Empty mandatory non-empty field in action description)",
TEST_CASE("Adding cyclic dependencies produces invalid graph", "[dag]") {
std::string const action1_id = "action1";
std::string const action2_id = "action2";
- auto const out1_desc = ArtifactDescription(action1_id, "out1");
- auto const out2_desc = ArtifactDescription(action2_id, "out2");
+ auto const out1_desc =
+ ArtifactDescription::CreateAction(action1_id, "out1");
+ auto const out2_desc =
+ ArtifactDescription::CreateAction(action2_id, "out2");
auto const action1_desc =
ActionDescription{{"out1"},
diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp
index dd9f59db..9dc2f667 100644
--- a/test/buildtool/execution_engine/executor/executor.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor.test.cpp
@@ -234,9 +234,10 @@ class TestApi : public IExecutionApi {
-> std::pair<TestApiConfig, RepositoryConfig> {
using path = std::filesystem::path;
- auto const local_cpp_desc = ArtifactDescription{path{"local.cpp"}, ""};
- auto const known_cpp_desc = ArtifactDescription{
- ArtifactDigest{"known.cpp", 0, /*is_tree=*/false}, ObjectType::File};
+ auto const local_cpp_desc =
+ ArtifactDescription::CreateLocal(path{"local.cpp"}, "");
+ auto const known_cpp_desc = ArtifactDescription::CreateKnown(
+ ArtifactDigest{"known.cpp", 0, /*is_tree=*/false}, ObjectType::File);
auto const test_action_desc = ActionDescription{
{"output1.exe", "output2.exe"},
diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp
index e499efae..18e30c70 100644
--- a/test/buildtool/execution_engine/executor/executor_api.test.hpp
+++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp
@@ -99,7 +99,7 @@ static inline void RunHelloWorldCompilation(
using path = std::filesystem::path;
SetupConfig(repo_config);
auto const main_cpp_desc =
- ArtifactDescription{path{"data/hello_world/main.cpp"}, ""};
+ ArtifactDescription::CreateLocal(path{"data/hello_world/main.cpp"}, "");
auto const& main_cpp_id = main_cpp_desc.Id();
std::string const make_hello_id = "make_hello";
auto* env_path = std::getenv("PATH");
@@ -118,7 +118,7 @@ static inline void RunHelloWorldCompilation(
env},
{{"src/main.cpp", main_cpp_desc}}};
auto const exec_desc =
- ArtifactDescription{make_hello_id, "out/hello_world"};
+ ArtifactDescription::CreateAction(make_hello_id, "out/hello_world");
auto const& exec_id = exec_desc.Id();
DependencyGraph g;
@@ -174,10 +174,10 @@ static inline void RunGreeterCompilation(
using path = std::filesystem::path;
SetupConfig(repo_config);
auto const greet_hpp_desc =
- ArtifactDescription{path{"data/greeter/greet.hpp"}, ""};
+ ArtifactDescription::CreateLocal(path{"data/greeter/greet.hpp"}, "");
auto const& greet_hpp_id = greet_hpp_desc.Id();
auto const greet_cpp_desc =
- ArtifactDescription{path{"data/greeter"} / greetcpp, ""};
+ ArtifactDescription::CreateLocal(path{"data/greeter"} / greetcpp, "");
auto const& greet_cpp_id = greet_cpp_desc.Id();
std::string const compile_greet_id = "compile_greet";
@@ -205,7 +205,7 @@ static inline void RunGreeterCompilation(
{"src/greet.cpp", greet_cpp_desc}}};
auto const greet_o_desc =
- ArtifactDescription{compile_greet_id, "out/greet.o"};
+ ArtifactDescription::CreateAction(compile_greet_id, "out/greet.o");
auto const& greet_o_id = greet_o_desc.Id();
std::string const make_lib_id = "make_lib";
@@ -216,11 +216,11 @@ static inline void RunGreeterCompilation(
{{"greet.o", greet_o_desc}}};
auto const main_cpp_desc =
- ArtifactDescription{path{"data/greeter/main.cpp"}, ""};
+ ArtifactDescription::CreateLocal(path{"data/greeter/main.cpp"}, "");
auto const& main_cpp_id = main_cpp_desc.Id();
auto const libgreet_desc =
- ArtifactDescription{make_lib_id, "out/libgreet.a"};
+ ArtifactDescription::CreateAction(make_lib_id, "out/libgreet.a");
auto const& libgreet_id = libgreet_desc.Id();
std::string const make_exe_id = "make_exe";
@@ -242,7 +242,8 @@ static inline void RunGreeterCompilation(
{"include/greet.hpp", greet_hpp_desc},
{"lib/libgreet.a", libgreet_desc}}};
- auto const exec_id = ArtifactDescription(make_exe_id, "out/greeter").Id();
+ auto const exec_id =
+ ArtifactDescription::CreateAction(make_exe_id, "out/greeter").Id();
DependencyGraph g;
CHECK(g.Add({compile_greet_desc, make_lib_desc, make_exe_desc}));
@@ -402,8 +403,10 @@ static inline void TestUploadAndDownloadTrees(
ArtifactBlob{bar_digest, bar, /*is_exec=*/false}}}));
// define known artifacts
- auto foo_desc = ArtifactDescription{foo_digest, ObjectType::File};
- auto bar_desc = ArtifactDescription{bar_digest, ObjectType::Symlink};
+ auto foo_desc =
+ ArtifactDescription::CreateKnown(foo_digest, ObjectType::File);
+ auto bar_desc =
+ ArtifactDescription::CreateKnown(bar_digest, ObjectType::Symlink);
DependencyGraph g{};
auto foo_id = g.AddArtifact(foo_desc);
@@ -560,7 +563,8 @@ static inline void TestRetrieveOutputDirectories(
SECTION("entire action output as directory") {
auto const make_tree_desc = create_action({}, {""});
- auto const root_desc = ArtifactDescription{make_tree_id, ""};
+ auto const root_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "");
DependencyGraph g{};
REQUIRE(g.AddAction(make_tree_desc));
@@ -605,9 +609,12 @@ static inline void TestRetrieveOutputDirectories(
SECTION("disjoint files and directories") {
auto const make_tree_desc = create_action({"foo", "bar"}, {"baz"});
- auto const foo_desc = ArtifactDescription{make_tree_id, "foo"};
- auto const bar_desc = ArtifactDescription{make_tree_id, "bar"};
- auto const baz_desc = ArtifactDescription{make_tree_id, "baz"};
+ auto const foo_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "foo");
+ auto const bar_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "bar");
+ auto const baz_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "baz");
DependencyGraph g{};
REQUIRE(g.AddAction(make_tree_desc));
@@ -669,10 +676,14 @@ static inline void TestRetrieveOutputDirectories(
SECTION("nested files and directories") {
auto const make_tree_desc =
create_action({"foo", "baz/bar"}, {"", "baz/baz"});
- auto const root_desc = ArtifactDescription{make_tree_id, ""};
- auto const foo_desc = ArtifactDescription{make_tree_id, "foo"};
- auto const bar_desc = ArtifactDescription{make_tree_id, "baz/bar"};
- auto const baz_desc = ArtifactDescription{make_tree_id, "baz/baz"};
+ auto const root_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "");
+ auto const foo_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "foo");
+ auto const bar_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "baz/bar");
+ auto const baz_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "baz/baz");
DependencyGraph g{};
REQUIRE(g.AddAction(make_tree_desc));
@@ -750,7 +761,8 @@ static inline void TestRetrieveOutputDirectories(
SECTION("non-existing outputs") {
SECTION("non-existing file") {
auto const make_tree_desc = create_action({"fool"}, {});
- auto const fool_desc = ArtifactDescription{make_tree_id, "fool"};
+ auto const fool_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "fool");
DependencyGraph g{};
REQUIRE(g.AddAction(make_tree_desc));
@@ -775,7 +787,8 @@ static inline void TestRetrieveOutputDirectories(
SECTION("non-existing directory") {
auto const make_tree_desc = create_action({"bazel"}, {});
- auto const bazel_desc = ArtifactDescription{make_tree_id, "bazel"};
+ auto const bazel_desc =
+ ArtifactDescription::CreateAction(make_tree_id, "bazel");
DependencyGraph g{};
REQUIRE(g.AddAction(make_tree_desc));
diff --git a/test/buildtool/execution_engine/traverser/TARGETS b/test/buildtool/execution_engine/traverser/TARGETS
index 9f1e1387..77603634 100644
--- a/test/buildtool/execution_engine/traverser/TARGETS
+++ b/test/buildtool/execution_engine/traverser/TARGETS
@@ -6,6 +6,7 @@
[ ["@", "catch2", "", "catch2"]
, ["", "catch-main"]
, ["utils", "container_matchers"]
+ , ["@", "src", "src/buildtool/common", "common"]
, ["@", "src", "src/buildtool/common", "artifact_factory"]
, ["@", "src", "src/buildtool/execution_engine/dag", "dag"]
, ["@", "src", "src/buildtool/execution_engine/traverser", "traverser"]
diff --git a/test/buildtool/execution_engine/traverser/traverser.test.cpp b/test/buildtool/execution_engine/traverser/traverser.test.cpp
index 2354aaf1..150f3d8c 100644
--- a/test/buildtool/execution_engine/traverser/traverser.test.cpp
+++ b/test/buildtool/execution_engine/traverser/traverser.test.cpp
@@ -167,10 +167,9 @@ class TestProject {
command.emplace_back("BUILD");
for (auto const& output : outputs) {
command.push_back(output);
- auto const out_id = ArtifactDescription{
- action_id,
- std::filesystem::path{
- output}}.Id();
+ auto const out_id = ArtifactDescription::CreateAction(
+ action_id, std::filesystem::path{output})
+ .Id();
auto [_, is_inserted] = artifacts_to_be_built_.insert(out_id);
if (!is_inserted) {
return false;