summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-03-07 15:44:28 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-03-11 15:59:05 +0100
commit5f6ff55e97104e46c1b5c2c94b39ea0fca35ca7c (patch)
tree9a8a70d311f2c55c20f426258455f9fb3037328a /test
parentb885deebf9fc02b9f1e849d91de93fadcfb71a73 (diff)
downloadjustbuild-5f6ff55e97104e46c1b5c2c94b39ea0fca35ca7c.tar.gz
just: Replace singletons for progress tracking and statistics...
...with regular instances that have controlled life-times. This avoids race conditions in tracking and reporting the results of analysis and build, as the serve endpoint can orchestrate multiple builds at the same time asynchronously. As a bonus side-effect this also ensures the correctness of the progress reporting per orchestrated build.
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/build_engine/target_map/TARGETS4
-rw-r--r--test/buildtool/build_engine/target_map/result_map.test.cpp45
-rw-r--r--test/buildtool/build_engine/target_map/target_map.test.cpp69
-rw-r--r--test/buildtool/execution_engine/executor/TARGETS6
-rw-r--r--test/buildtool/execution_engine/executor/executor.test.cpp47
-rw-r--r--test/buildtool/execution_engine/executor/executor_api.test.hpp114
-rwxr-xr-xtest/buildtool/execution_engine/executor/executor_api_local.test.cpp30
-rwxr-xr-xtest/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp18
-rw-r--r--test/buildtool/graph_traverser/TARGETS1
-rw-r--r--test/buildtool/graph_traverser/graph_traverser.test.hpp155
-rw-r--r--test/utils/hermeticity/local.hpp1
11 files changed, 341 insertions, 149 deletions
diff --git a/test/buildtool/build_engine/target_map/TARGETS b/test/buildtool/build_engine/target_map/TARGETS
index 8f894ca1..877c3b76 100644
--- a/test/buildtool/build_engine/target_map/TARGETS
+++ b/test/buildtool/build_engine/target_map/TARGETS
@@ -7,6 +7,8 @@
, ["", "catch-main"]
, ["@", "src", "src/buildtool/file_system", "file_system_manager"]
, ["@", "src", "src/buildtool/build_engine/target_map", "result_map"]
+ , ["@", "src", "src/buildtool/common", "common"]
+ , ["@", "src", "src/buildtool/progress_reporting", "progress"]
]
, "stage": ["test", "buildtool", "build_engine", "target_map"]
}
@@ -23,6 +25,8 @@
, ["@", "src", "src/buildtool/build_engine/base_maps", "source_map"]
, ["@", "src", "src/buildtool/build_engine/base_maps", "targets_file_map"]
, ["@", "src", "src/buildtool/build_engine/target_map", "target_map"]
+ , ["@", "src", "src/buildtool/common", "common"]
+ , ["@", "src", "src/buildtool/progress_reporting", "progress"]
, ["@", "src", "src/buildtool/storage", "storage"]
, ["utils", "local_hermeticity"]
]
diff --git a/test/buildtool/build_engine/target_map/result_map.test.cpp b/test/buildtool/build_engine/target_map/result_map.test.cpp
index bf246651..7f23942b 100644
--- a/test/buildtool/build_engine/target_map/result_map.test.cpp
+++ b/test/buildtool/build_engine/target_map/result_map.test.cpp
@@ -20,7 +20,9 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/build_engine/target_map/result_map.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
namespace {
@@ -53,14 +55,17 @@ namespace {
TEST_CASE("empty map", "[result_map]") {
using BuildMaps::Target::ResultTargetMap;
ResultTargetMap map{0};
+ Statistics stats{};
+ Progress progress{};
- CHECK(map.ToResult().actions.empty());
- CHECK(map.ToResult().blobs.empty());
+ CHECK(map.ToResult(&stats, &progress).actions.empty());
+ CHECK(map.ToResult(&stats, &progress).blobs.empty());
- CHECK(map.ToJson() == R"({"actions": {}, "blobs": [], "trees": {}})"_json);
+ CHECK(map.ToJson(&stats, &progress) ==
+ R"({"actions": {}, "blobs": [], "trees": {}})"_json);
auto filename = (GetTestDir() / "test_empty.graph").string();
- map.ToFile(filename);
+ map.ToFile(filename, &stats, &progress);
std::ifstream file(filename);
nlohmann::json from_file{};
file >> from_file;
@@ -97,19 +102,22 @@ TEST_CASE("origins creation", "[result_map]") {
CreateAnalysedTarget(
{}, std::vector<ActionDescription::Ptr>{baz}, {})));
- auto result = map.ToResult();
+ Statistics stats{};
+ Progress progress{};
+ auto result = map.ToResult(&stats, &progress);
REQUIRE(result.actions.size() == 3);
CHECK(result.blobs.empty());
auto expect_foo = foo->ToJson();
auto expect_bar = bar->ToJson();
auto expect_baz = baz->ToJson();
- CHECK(map.ToJson() == nlohmann::json{{"actions",
- {{foo->Id(), expect_foo},
- {bar->Id(), expect_bar},
- {baz->Id(), expect_baz}}},
- {"blobs", nlohmann::json::array()},
- {"trees", nlohmann::json::object()}});
+ CHECK(map.ToJson(&stats, &progress) ==
+ nlohmann::json{{"actions",
+ {{foo->Id(), expect_foo},
+ {bar->Id(), expect_bar},
+ {baz->Id(), expect_baz}}},
+ {"blobs", nlohmann::json::array()},
+ {"trees", nlohmann::json::object()}});
expect_foo["origins"] =
R"([{"target": ["@", "", "", "foobar"], "config": {}, "subtask":
@@ -122,7 +130,7 @@ TEST_CASE("origins creation", "[result_map]") {
0}])"_json;
auto filename = (GetTestDir() / "test_with_origins.graph").string();
- map.ToFile(filename);
+ map.ToFile(filename, &stats, &progress);
std::ifstream file(filename);
nlohmann::json from_file{};
file >> from_file;
@@ -146,16 +154,19 @@ TEST_CASE("blobs uniqueness", "[result_map]") {
{},
CreateAnalysedTarget({}, {}, {"bar", "baz"})));
- auto result = map.ToResult();
+ Statistics stats{};
+ Progress progress{};
+ auto result = map.ToResult(&stats, &progress);
CHECK(result.actions.empty());
CHECK(result.blobs.size() == 3);
- CHECK(map.ToJson() == nlohmann::json{{"actions", nlohmann::json::object()},
- {"blobs", {"bar", "baz", "foo"}},
- {"trees", nlohmann::json::object()}});
+ CHECK(map.ToJson(&stats, &progress) ==
+ nlohmann::json{{"actions", nlohmann::json::object()},
+ {"blobs", {"bar", "baz", "foo"}},
+ {"trees", nlohmann::json::object()}});
auto filename = (GetTestDir() / "test_unique_blobs.graph").string();
- map.ToFile</*kIncludeOrigins=*/false>(filename);
+ map.ToFile</*kIncludeOrigins=*/false>(filename, &stats, &progress);
std::ifstream file(filename);
nlohmann::json from_file{};
file >> from_file;
diff --git a/test/buildtool/build_engine/target_map/target_map.test.cpp b/test/buildtool/build_engine/target_map/target_map.test.cpp
index dd7c19a9..5918dac9 100644
--- a/test/buildtool/build_engine/target_map/target_map.test.cpp
+++ b/test/buildtool/build_engine/target_map/target_map.test.cpp
@@ -23,8 +23,10 @@
#include "src/buildtool/build_engine/base_maps/targets_file_map.hpp"
#include "src/buildtool/build_engine/expression/expression.hpp"
#include "src/buildtool/build_engine/target_map/target_map.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "src/buildtool/storage/storage.hpp"
#include "test/utils/hermeticity/local.hpp"
@@ -82,8 +84,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "simple targets", "[target_map]") {
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -92,7 +95,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "simple targets", "[target_map]") {
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
AnalysedTargetPtr result;
bool error{false};
@@ -431,8 +435,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -441,7 +446,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
std::vector<AnalysedTargetPtr> result;
bool error{false};
@@ -480,7 +486,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
CHECK(error_msg == "NONE");
CHECK(result[0]->Artifacts() == result[1]->Artifacts());
CHECK(result[0]->Artifacts() != result[2]->Artifacts());
- auto analysis_result = result_map.ToResult();
+ Progress progress{};
+ auto analysis_result = result_map.ToResult(&stats, &progress);
CHECK(analysis_result.actions.size() == 2);
}
@@ -502,8 +509,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -512,7 +520,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
AnalysedTargetPtr result;
bool error{false};
@@ -584,8 +593,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "built-in rules", "[target_map]") {
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -594,7 +604,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "built-in rules", "[target_map]") {
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
AnalysedTargetPtr result;
bool error{false};
std::string error_msg;
@@ -776,8 +787,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "target reference", "[target_map]") {
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -786,7 +798,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "target reference", "[target_map]") {
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
AnalysedTargetPtr result;
bool error{false};
@@ -901,8 +914,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "trees", "[target_map]") {
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -911,7 +925,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "trees", "[target_map]") {
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
AnalysedTargetPtr result;
bool error{false};
@@ -992,8 +1007,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -1002,7 +1018,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
AnalysedTargetPtr result;
bool error{false};
@@ -1140,8 +1157,9 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "wrong arguments", "[target_map]") {
auto rule_map =
BuildMaps::Base::CreateRuleMap(&rule_file_map, &expr_map, &repo_config);
BuildMaps::Target::ResultTargetMap result_map{0};
- auto absent_target_map =
- BuildMaps::Target::CreateAbsentTargetMap(&result_map, &repo_config, 0);
+ Statistics stats{};
+ auto absent_target_map = BuildMaps::Target::CreateAbsentTargetMap(
+ &result_map, &repo_config, &stats, 0);
auto target_map =
BuildMaps::Target::CreateTargetMap(&source,
&targets_file_map,
@@ -1150,7 +1168,8 @@ TEST_CASE_METHOD(HermeticLocalTestFixture, "wrong arguments", "[target_map]") {
&absent_target_map,
&result_map,
&repo_config,
- Storage::Instance().TargetCache());
+ Storage::Instance().TargetCache(),
+ &stats);
AnalysedTargetPtr result;
bool error{false};
diff --git a/test/buildtool/execution_engine/executor/TARGETS b/test/buildtool/execution_engine/executor/TARGETS
index 991cecc3..896b7803 100644
--- a/test/buildtool/execution_engine/executor/TARGETS
+++ b/test/buildtool/execution_engine/executor/TARGETS
@@ -10,10 +10,12 @@
, "srcs": ["executor.test.cpp"]
, "private-deps":
[ ["@", "src", "src/buildtool/common", "artifact_factory"]
+ , ["@", "src", "src/buildtool/common", "common"]
, ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/common", "common"]
, ["@", "src", "src/buildtool/execution_engine/dag", "dag"]
, ["@", "src", "src/buildtool/execution_engine/executor", "executor"]
+ , ["@", "src", "src/buildtool/progress_reporting", "progress"]
, ["", "catch-main"]
, ["@", "catch2", "", "catch2"]
]
@@ -27,11 +29,13 @@
, "private-deps":
[ "executor_api_tests"
, ["@", "src", "src/buildtool/common", "artifact_factory"]
+ , ["@", "src", "src/buildtool/common", "common"]
, ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/local", "local"]
, ["@", "src", "src/buildtool/execution_api/remote", "config"]
, ["@", "src", "src/buildtool/execution_engine/dag", "dag"]
, ["@", "src", "src/buildtool/execution_engine/executor", "executor"]
+ , ["@", "src", "src/buildtool/progress_reporting", "progress"]
, ["utils", "catch-main-remote-execution"]
, ["utils", "local_hermeticity"]
, ["@", "catch2", "", "catch2"]
@@ -46,10 +50,12 @@
, "private-deps":
[ "executor_api_tests"
, ["@", "src", "src/buildtool/common", "artifact_factory"]
+ , ["@", "src", "src/buildtool/common", "common"]
, ["@", "src", "src/buildtool/common", "config"]
, ["@", "src", "src/buildtool/execution_api/remote", "bazel"]
, ["@", "src", "src/buildtool/execution_api/remote", "config"]
, ["@", "src", "src/buildtool/execution_engine/executor", "executor"]
+ , ["@", "src", "src/buildtool/progress_reporting", "progress"]
, ["utils", "catch-main-remote-execution"]
, ["@", "catch2", "", "catch2"]
]
diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp
index 0b4561e0..72bd23bb 100644
--- a/test/buildtool/execution_engine/executor/executor.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor.test.cpp
@@ -19,9 +19,11 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/artifact_factory.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
/// \brief Mockup API test config.
struct TestApiConfig {
@@ -267,7 +269,10 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
SECTION("Processing succeeds for valid config") {
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -277,7 +282,10 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
config.artifacts["local.cpp"].uploads = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(not runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -287,7 +295,10 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
config.artifacts["known.cpp"].available = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(not runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -320,7 +331,10 @@ TEST_CASE("Executor: Process action", "[executor]") {
SECTION("Processing succeeds for valid config") {
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -333,7 +347,10 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.response.cached = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -346,7 +363,10 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.artifacts["output2.exe"].available = false;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -362,7 +382,10 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.execution.failed = true;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -375,7 +398,10 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.response.exit_code = 1;
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
@@ -391,7 +417,10 @@ TEST_CASE("Executor: Process action", "[executor]") {
config.execution.outputs = {"output1.exe" /*, "output2.exe"*/};
auto api = TestApi::Ptr{new TestApi{config}};
- Executor runner{&repo_config, api.get(), api.get(), {}, {}};
+ Statistics stats{};
+ Progress progress{};
+ Executor runner{
+ &repo_config, api.get(), api.get(), {}, {}, &stats, &progress};
CHECK(runner.Process(g.ArtifactNodeWithId(local_cpp_id)));
CHECK(runner.Process(g.ArtifactNodeWithId(known_cpp_id)));
diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp
index b851c5b8..634cc38f 100644
--- a/test/buildtool/execution_engine/executor/executor_api.test.hpp
+++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp
@@ -18,15 +18,18 @@
#include <functional>
#include "catch2/catch_test_macros.hpp"
+#include "gsl/gsl"
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/artifact_description.hpp"
#include "src/buildtool/common/artifact_factory.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/execution_engine/dag/dag.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "test/utils/test_env.hpp"
using ApiFactory = std::function<IExecutionApi::Ptr()>;
@@ -80,11 +83,14 @@ template <class Executor>
return tree_artifact->Content().Info();
}
-static inline void RunHelloWorldCompilation(RepositoryConfig* repo_config,
- ApiFactory const& factory,
- bool is_hermetic = true,
- int expected_queued = 0,
- int expected_cached = 0) {
+static inline void RunHelloWorldCompilation(
+ RepositoryConfig* repo_config,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
+ ApiFactory const& factory,
+ bool is_hermetic = true,
+ int expected_queued = 0,
+ int expected_cached = 0) {
using path = std::filesystem::path;
SetupConfig(repo_config);
auto const main_cpp_desc =
@@ -119,7 +125,9 @@ static inline void RunHelloWorldCompilation(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
// upload local artifacts
auto const* main_cpp_node = g.ArtifactNodeWithId(main_cpp_id);
@@ -129,8 +137,8 @@ static inline void RunHelloWorldCompilation(RepositoryConfig* repo_config,
// process action
CHECK(runner.Process(g.ArtifactNodeWithId(exec_id)->BuilderActionNode()));
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == expected_queued);
- CHECK(Statistics::Instance().ActionsCachedCounter() == expected_cached);
+ CHECK(stats->ActionsQueuedCounter() == expected_queued);
+ CHECK(stats->ActionsCachedCounter() == expected_cached);
}
auto tmpdir = GetTestDir();
@@ -147,12 +155,15 @@ static inline void RunHelloWorldCompilation(RepositoryConfig* repo_config,
}
}
-static inline void RunGreeterCompilation(RepositoryConfig* repo_config,
- ApiFactory const& factory,
- std::string const& greetcpp,
- bool is_hermetic = true,
- int expected_queued = 0,
- int expected_cached = 0) {
+static inline void RunGreeterCompilation(
+ RepositoryConfig* repo_config,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
+ ApiFactory const& factory,
+ std::string const& greetcpp,
+ bool is_hermetic = true,
+ int expected_queued = 0,
+ int expected_cached = 0) {
using path = std::filesystem::path;
SetupConfig(repo_config);
auto const greet_hpp_desc =
@@ -234,7 +245,9 @@ static inline void RunGreeterCompilation(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
// upload local artifacts
for (auto const& id : {greet_hpp_id, greet_cpp_id, main_cpp_id}) {
@@ -250,8 +263,8 @@ static inline void RunGreeterCompilation(RepositoryConfig* repo_config,
runner.Process(g.ArtifactNodeWithId(libgreet_id)->BuilderActionNode()));
CHECK(runner.Process(g.ArtifactNodeWithId(exec_id)->BuilderActionNode()));
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == expected_queued);
- CHECK(Statistics::Instance().ActionsCachedCounter() == expected_cached);
+ CHECK(stats->ActionsQueuedCounter() == expected_queued);
+ CHECK(stats->ActionsCachedCounter() == expected_cached);
}
auto tmpdir = GetTestDir();
@@ -277,32 +290,41 @@ static inline void RunGreeterCompilation(RepositoryConfig* repo_config,
[[maybe_unused]] static void TestHelloWorldCompilation(
RepositoryConfig* repo_config,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
ApiFactory const& factory,
bool is_hermetic = true) {
SetupConfig(repo_config);
// expecting 1 action queued, 0 results from cache
// NOLINTNEXTLINE
- RunHelloWorldCompilation(repo_config, factory, is_hermetic, 1, 0);
+ RunHelloWorldCompilation(
+ repo_config, stats, progress, factory, is_hermetic, 1, 0);
SECTION("Running same compilation again") {
// expecting 2 actions queued, 1 result from cache
// NOLINTNEXTLINE
- RunHelloWorldCompilation(repo_config, factory, is_hermetic, 2, 1);
+ RunHelloWorldCompilation(
+ repo_config, stats, progress, factory, is_hermetic, 2, 1);
}
}
[[maybe_unused]] static void TestGreeterCompilation(
RepositoryConfig* repo_config,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
ApiFactory const& factory,
bool is_hermetic = true) {
SetupConfig(repo_config);
// expecting 3 action queued, 0 results from cache
// NOLINTNEXTLINE
- RunGreeterCompilation(repo_config, factory, "greet.cpp", is_hermetic, 3, 0);
+ RunGreeterCompilation(
+ repo_config, stats, progress, factory, "greet.cpp", is_hermetic, 3, 0);
SECTION("Running same compilation again") {
// expecting 6 actions queued, 3 results from cache
RunGreeterCompilation(repo_config,
+ stats,
+ progress,
factory,
"greet.cpp",
is_hermetic,
@@ -313,6 +335,8 @@ static inline void RunGreeterCompilation(RepositoryConfig* repo_config,
SECTION("Running modified compilation") {
// expecting 6 actions queued, 2 results from cache
RunGreeterCompilation(repo_config,
+ stats,
+ progress,
factory,
"greet_mod.cpp",
is_hermetic,
@@ -321,11 +345,14 @@ static inline void RunGreeterCompilation(RepositoryConfig* repo_config,
}
}
-static inline void TestUploadAndDownloadTrees(RepositoryConfig* repo_config,
- ApiFactory const& factory,
- bool /*is_hermetic*/ = true,
- int /*expected_queued*/ = 0,
- int /*expected_cached*/ = 0) {
+static inline void TestUploadAndDownloadTrees(
+ RepositoryConfig* repo_config,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
+ ApiFactory const& factory,
+ bool /*is_hermetic*/ = true,
+ int /*expected_queued*/ = 0,
+ int /*expected_cached*/ = 0) {
SetupConfig(repo_config);
auto tmpdir = GetTestDir();
auto* env_path = std::getenv("PATH");
@@ -366,7 +393,9 @@ static inline void TestUploadAndDownloadTrees(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
REQUIRE(runner.Process(g.ArtifactNodeWithId(foo_id)));
REQUIRE(runner.Process(g.ArtifactNodeWithId(bar_id)));
@@ -468,11 +497,14 @@ static inline void TestUploadAndDownloadTrees(RepositoryConfig* repo_config,
}
}
-static inline void TestRetrieveOutputDirectories(RepositoryConfig* repo_config,
- ApiFactory const& factory,
- bool /*is_hermetic*/ = true,
- int /*expected_queued*/ = 0,
- int /*expected_cached*/ = 0) {
+static inline void TestRetrieveOutputDirectories(
+ RepositoryConfig* repo_config,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
+ ApiFactory const& factory,
+ bool /*is_hermetic*/ = true,
+ int /*expected_queued*/ = 0,
+ int /*expected_cached*/ = 0) {
SetupConfig(repo_config);
auto tmpdir = GetTestDir();
@@ -522,7 +554,9 @@ static inline void TestRetrieveOutputDirectories(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
REQUIRE(runner.Process(action));
// read output
@@ -570,7 +604,9 @@ static inline void TestRetrieveOutputDirectories(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
REQUIRE(runner.Process(action));
// read output
@@ -634,7 +670,9 @@ static inline void TestRetrieveOutputDirectories(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
REQUIRE(runner.Process(action));
// read output
@@ -703,7 +741,9 @@ static inline void TestRetrieveOutputDirectories(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
CHECK_FALSE(runner.Process(action));
}
@@ -725,7 +765,9 @@ static inline void TestRetrieveOutputDirectories(RepositoryConfig* repo_config,
api.get(),
api.get(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ stats,
+ progress};
CHECK_FALSE(runner.Process(action));
}
}
diff --git a/test/buildtool/execution_engine/executor/executor_api_local.test.cpp b/test/buildtool/execution_engine/executor/executor_api_local.test.cpp
index f196e98b..26d8993f 100755
--- a/test/buildtool/execution_engine/executor/executor_api_local.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor_api_local.test.cpp
@@ -14,9 +14,11 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "test/buildtool/execution_engine/executor/executor_api.test.hpp"
#include "test/utils/hermeticity/local.hpp"
@@ -32,30 +34,42 @@ TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Compile hello world",
"[executor]") {
RepositoryConfig repo_config{};
- TestHelloWorldCompilation(
- &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
+ Statistics stats{};
+ Progress progress{};
+ TestHelloWorldCompilation(&repo_config, &stats, &progress, [&] {
+ return std::make_unique<LocalApi>(&repo_config);
+ });
}
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Compile greeter",
"[executor]") {
RepositoryConfig repo_config{};
- TestGreeterCompilation(
- &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
+ Statistics stats{};
+ Progress progress{};
+ TestGreeterCompilation(&repo_config, &stats, &progress, [&] {
+ return std::make_unique<LocalApi>(&repo_config);
+ });
}
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Upload and download trees",
"[executor]") {
RepositoryConfig repo_config{};
- TestUploadAndDownloadTrees(
- &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
+ Statistics stats{};
+ Progress progress{};
+ TestUploadAndDownloadTrees(&repo_config, &stats, &progress, [&] {
+ return std::make_unique<LocalApi>(&repo_config);
+ });
}
TEST_CASE_METHOD(HermeticLocalTestFixture,
"Executor<LocalApi>: Retrieve output directories",
"[executor]") {
RepositoryConfig repo_config{};
- TestRetrieveOutputDirectories(
- &repo_config, [&] { return std::make_unique<LocalApi>(&repo_config); });
+ Statistics stats{};
+ Progress progress{};
+ TestRetrieveOutputDirectories(&repo_config, &stats, &progress, [&] {
+ return std::make_unique<LocalApi>(&repo_config);
+ });
}
diff --git a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
index 4df56ec2..56094fc3 100755
--- a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
@@ -14,9 +14,11 @@
#include "catch2/catch_test_macros.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/execution_engine/executor/executor.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "test/buildtool/execution_engine/executor/executor_api.test.hpp"
TEST_CASE("Executor<BazelApi>: Upload blob", "[executor]") {
@@ -32,6 +34,8 @@ TEST_CASE("Executor<BazelApi>: Upload blob", "[executor]") {
TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") {
RepositoryConfig repo_config{};
+ Statistics stats{};
+ Progress progress{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
@@ -39,6 +43,8 @@ TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") {
TestHelloWorldCompilation(
&repo_config,
+ &stats,
+ &progress,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
@@ -48,6 +54,8 @@ TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") {
TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") {
RepositoryConfig repo_config{};
+ Statistics stats{};
+ Progress progress{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
@@ -55,6 +63,8 @@ TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") {
TestGreeterCompilation(
&repo_config,
+ &stats,
+ &progress,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
@@ -64,6 +74,8 @@ TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") {
TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") {
RepositoryConfig repo_config{};
+ Statistics stats{};
+ Progress progress{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
@@ -71,6 +83,8 @@ TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") {
TestUploadAndDownloadTrees(
&repo_config,
+ &stats,
+ &progress,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
@@ -80,6 +94,8 @@ TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") {
TEST_CASE("Executor<BazelApi>: Retrieve output directories", "[executor]") {
RepositoryConfig repo_config{};
+ Statistics stats{};
+ Progress progress{};
ExecutionConfiguration config;
config.skip_cache_lookup = false;
@@ -87,6 +103,8 @@ TEST_CASE("Executor<BazelApi>: Retrieve output directories", "[executor]") {
TestRetrieveOutputDirectories(
&repo_config,
+ &stats,
+ &progress,
[&] {
return BazelApi::Ptr{new BazelApi{
"remote-execution", info->host, info->port, config}};
diff --git a/test/buildtool/graph_traverser/TARGETS b/test/buildtool/graph_traverser/TARGETS
index e2da438c..d4936283 100644
--- a/test/buildtool/graph_traverser/TARGETS
+++ b/test/buildtool/graph_traverser/TARGETS
@@ -9,6 +9,7 @@
, ["@", "src", "src/buildtool/file_system", "file_system_manager"]
, ["@", "src", "src/buildtool/file_system", "jsonfs"]
, ["@", "src", "src/buildtool/graph_traverser", "graph_traverser"]
+ , ["@", "src", "src/buildtool/progress_reporting", "progress"]
, ["utils", "test_env"]
]
, "stage": ["test", "buildtool", "graph_traverser"]
diff --git a/test/buildtool/graph_traverser/graph_traverser.test.hpp b/test/buildtool/graph_traverser/graph_traverser.test.hpp
index dda1bd2d..a35c56b8 100644
--- a/test/buildtool/graph_traverser/graph_traverser.test.hpp
+++ b/test/buildtool/graph_traverser/graph_traverser.test.hpp
@@ -26,6 +26,7 @@
#include "src/buildtool/file_system/jsonfs.hpp"
#include "src/buildtool/graph_traverser/graph_traverser.hpp"
#include "src/buildtool/logging/logger.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
#include "src/utils/cpp/json.hpp"
#include "test/utils/test_env.hpp"
@@ -146,10 +147,14 @@ inline void SetLauncher() {
SetLauncher();
auto const clargs = p.CmdLineArgs();
+ Statistics stats{};
+ Progress progress{};
GraphTraverser const gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -162,8 +167,8 @@ inline void SetLauncher() {
CHECK(contents == "Hello, World!\n");
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 2);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 2);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
SECTION("Executable is retrieved as executable") {
@@ -172,7 +177,9 @@ inline void SetLauncher() {
clargs_exec.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const exec_result = gt_get_exec.BuildAndStage(
clargs_exec.graph_description, clargs_exec.artifacts);
@@ -184,9 +191,8 @@ inline void SetLauncher() {
CHECK(FileSystemManager::Type(exec_path) == ObjectType::Executable);
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() ==
- 3); // One more action queued
- CHECK(Statistics::Instance().ActionsCachedCounter() ==
+ CHECK(stats.ActionsQueuedCounter() == 3); // One more action queued
+ CHECK(stats.ActionsCachedCounter() ==
1); // But that action was cached
}
}
@@ -197,10 +203,14 @@ inline void SetLauncher() {
SetLauncher();
auto const clargs = p.CmdLineArgs();
+ Statistics stats{};
+ Progress progress{};
GraphTraverser const gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -209,8 +219,8 @@ inline void SetLauncher() {
CHECK(FileSystemManager::IsFile(result->output_paths.at(0)));
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 0);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 0);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
}
@@ -220,10 +230,14 @@ inline void SetLauncher() {
SetLauncher();
auto const clargs = p.CmdLineArgs();
+ Statistics stats{};
+ Progress progress{};
GraphTraverser const gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -236,7 +250,9 @@ inline void SetLauncher() {
clargs_full_build.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const full_build_result = gt_full_build.BuildAndStage(
clargs_full_build.graph_description, clargs_full_build.artifacts);
@@ -245,11 +261,11 @@ inline void SetLauncher() {
CHECK(FileSystemManager::IsFile(full_build_result->output_paths.at(0)));
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 8);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 3);
+ CHECK(stats.ActionsQueuedCounter() == 8);
+ CHECK(stats.ActionsCachedCounter() == 3);
}
else {
- CHECK(Statistics::Instance().ActionsCachedCounter() > 0);
+ CHECK(stats.ActionsCachedCounter() > 0);
}
}
@@ -260,10 +276,14 @@ inline void SetLauncher() {
SetLauncher();
auto const clargs_update_cpp =
full_hello_world.CmdLineArgs("_entry_points_upload_source");
+ Statistics stats{};
+ Progress progress{};
GraphTraverser const gt_upload{clargs_update_cpp.gtargs,
full_hello_world.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const cpp_result = gt_upload.BuildAndStage(
clargs_update_cpp.graph_description, clargs_update_cpp.artifacts);
@@ -273,8 +293,8 @@ inline void SetLauncher() {
CHECK(FileSystemManager::IsFile(cpp_result->output_paths.at(0)));
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 0);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 0);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
TestProject hello_world_known_cpp("hello_world_known_source");
@@ -282,7 +302,9 @@ inline void SetLauncher() {
GraphTraverser const gt{clargs.gtargs,
full_hello_world.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -291,11 +313,11 @@ inline void SetLauncher() {
CHECK(FileSystemManager::IsFile(result->output_paths.at(0)));
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 2);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 2);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
else {
- CHECK(Statistics::Instance().ActionsQueuedCounter() >= 2);
+ CHECK(stats.ActionsQueuedCounter() >= 2);
}
}
@@ -304,10 +326,14 @@ static void TestBlobsUploadedAndUsed(bool is_hermetic = true) {
auto const clargs = p.CmdLineArgs();
SetLauncher();
+ Statistics stats{};
+ Progress progress{};
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -321,11 +347,11 @@ static void TestBlobsUploadedAndUsed(bool is_hermetic = true) {
CHECK(contents == "this is a test to check if blobs are uploaded");
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 1);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 1);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
else {
- CHECK(Statistics::Instance().ActionsQueuedCounter() >= 1);
+ CHECK(stats.ActionsQueuedCounter() >= 1);
}
}
@@ -334,10 +360,14 @@ static void TestEnvironmentVariablesSetAndUsed(bool is_hermetic = true) {
auto const clargs = p.CmdLineArgs();
SetLauncher();
+ Statistics stats{};
+ Progress progress{};
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -351,11 +381,11 @@ static void TestEnvironmentVariablesSetAndUsed(bool is_hermetic = true) {
CHECK(contents == "content from environment variable");
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 1);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 1);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
else {
- CHECK(Statistics::Instance().ActionsQueuedCounter() >= 1);
+ CHECK(stats.ActionsQueuedCounter() >= 1);
}
}
@@ -364,10 +394,14 @@ static void TestTreesUsed(bool is_hermetic = true) {
auto const clargs = p.CmdLineArgs();
SetLauncher();
+ Statistics stats{};
+ Progress progress{};
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -381,11 +415,11 @@ static void TestTreesUsed(bool is_hermetic = true) {
CHECK(contents == "this is a test to check if blobs are uploaded");
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 2);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 2);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
else {
- CHECK(Statistics::Instance().ActionsQueuedCounter() >= 2);
+ CHECK(stats.ActionsQueuedCounter() >= 2);
}
}
@@ -394,10 +428,14 @@ static void TestNestedTreesUsed(bool is_hermetic = true) {
auto const clargs = p.CmdLineArgs();
SetLauncher();
+ Statistics stats{};
+ Progress progress{};
GraphTraverser gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -411,24 +449,29 @@ static void TestNestedTreesUsed(bool is_hermetic = true) {
CHECK(contents == "this is a test to check if blobs are uploaded");
if (is_hermetic) {
- CHECK(Statistics::Instance().ActionsQueuedCounter() == 1);
- CHECK(Statistics::Instance().ActionsCachedCounter() == 0);
+ CHECK(stats.ActionsQueuedCounter() == 1);
+ CHECK(stats.ActionsCachedCounter() == 0);
}
else {
- CHECK(Statistics::Instance().ActionsQueuedCounter() >= 1);
+ CHECK(stats.ActionsQueuedCounter() >= 1);
}
}
static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
TestProject p("flaky_hello_world");
+ Statistics stats{};
+ Progress progress{};
+
{
SetLauncher();
auto clargs = p.CmdLineArgs("_entry_points_ctimes");
GraphTraverser const gt{clargs.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -445,13 +488,15 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
GraphTraverser const gt_output{clargs_output.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
REQUIRE(gt_output.BuildAndStage(clargs_output.graph_description,
clargs_output.artifacts));
- CHECK(Statistics::Instance().ActionsFlakyCounter() == 1);
- CHECK(Statistics::Instance().RebuiltActionComparedCounter() == 1);
- CHECK(Statistics::Instance().RebuiltActionMissingCounter() == 1);
- Statistics::Instance().Reset();
+ CHECK(stats.ActionsFlakyCounter() == 1);
+ CHECK(stats.RebuiltActionComparedCounter() == 1);
+ CHECK(stats.RebuiltActionMissingCounter() == 1);
+ stats.Reset();
// make_exe[flaky]->make_output[miss]->strip_time [miss]
auto clargs_stripped = p.CmdLineArgs("_entry_points_stripped");
@@ -460,13 +505,15 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
clargs_stripped.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
REQUIRE(gt_stripped.BuildAndStage(clargs_stripped.graph_description,
clargs_stripped.artifacts));
- CHECK(Statistics::Instance().ActionsFlakyCounter() == 1);
- CHECK(Statistics::Instance().RebuiltActionComparedCounter() == 1);
- CHECK(Statistics::Instance().RebuiltActionMissingCounter() == 2);
- Statistics::Instance().Reset();
+ CHECK(stats.ActionsFlakyCounter() == 1);
+ CHECK(stats.RebuiltActionComparedCounter() == 1);
+ CHECK(stats.RebuiltActionMissingCounter() == 2);
+ stats.Reset();
// make_exe[flaky]->make_output[miss]->strip_time[miss]->list_ctimes [flaky]
auto clargs_ctimes = p.CmdLineArgs("_entry_points_ctimes");
@@ -474,12 +521,14 @@ static void TestFlakyHelloWorldDetected(bool /*is_hermetic*/ = true) {
GraphTraverser const gt_ctimes{clargs_ctimes.gtargs,
p.GetRepoConfig(),
RemoteExecutionConfig::PlatformProperties(),
- RemoteExecutionConfig::DispatchList()};
+ RemoteExecutionConfig::DispatchList(),
+ &stats,
+ &progress};
REQUIRE(gt_ctimes.BuildAndStage(clargs_ctimes.graph_description,
clargs_ctimes.artifacts));
- CHECK(Statistics::Instance().ActionsFlakyCounter() == 2);
- CHECK(Statistics::Instance().RebuiltActionComparedCounter() == 2);
- CHECK(Statistics::Instance().RebuiltActionMissingCounter() == 2);
+ CHECK(stats.ActionsFlakyCounter() == 2);
+ CHECK(stats.RebuiltActionComparedCounter() == 2);
+ CHECK(stats.RebuiltActionMissingCounter() == 2);
}
#endif // INCLUDED_SRC_TEST_BUILDTOOL_GRAPH_GRAVERSER_GRAPH_TRAVERSER_TEST_HPP
diff --git a/test/utils/hermeticity/local.hpp b/test/utils/hermeticity/local.hpp
index 2b67cf10..b774c20a 100644
--- a/test/utils/hermeticity/local.hpp
+++ b/test/utils/hermeticity/local.hpp
@@ -25,7 +25,6 @@ class HermeticLocalTestFixture {
public:
HermeticLocalTestFixture() noexcept {
static int id{};
- Statistics::Instance().Reset();
CreateAndSetCleanDiskCache(id++);
}