summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildtool/build_engine/target_map/TARGETS2
-rw-r--r--src/buildtool/build_engine/target_map/absent_target_map.cpp14
-rw-r--r--src/buildtool/build_engine/target_map/absent_target_map.hpp2
-rw-r--r--src/buildtool/build_engine/target_map/built_in_rules.cpp9
-rw-r--r--src/buildtool/build_engine/target_map/built_in_rules.hpp2
-rw-r--r--src/buildtool/build_engine/target_map/export.cpp7
-rw-r--r--src/buildtool/build_engine/target_map/export.hpp2
-rw-r--r--src/buildtool/build_engine/target_map/result_map.hpp22
-rw-r--r--src/buildtool/build_engine/target_map/target_map.cpp26
-rw-r--r--src/buildtool/build_engine/target_map/target_map.hpp2
-rw-r--r--src/buildtool/common/statistics.hpp5
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp71
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.hpp33
-rw-r--r--src/buildtool/main/TARGETS5
-rw-r--r--src/buildtool/main/analyse.cpp4
-rw-r--r--src/buildtool/main/analyse.hpp2
-rw-r--r--src/buildtool/main/main.cpp25
-rw-r--r--src/buildtool/progress_reporting/TARGETS10
-rw-r--r--src/buildtool/progress_reporting/progress.hpp5
-rw-r--r--src/buildtool/progress_reporting/progress_reporter.cpp22
-rw-r--r--src/buildtool/progress_reporting/progress_reporter.hpp8
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp22
-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
33 files changed, 541 insertions, 249 deletions
diff --git a/src/buildtool/build_engine/target_map/TARGETS b/src/buildtool/build_engine/target_map/TARGETS
index b753e503..38c261d5 100644
--- a/src/buildtool/build_engine/target_map/TARGETS
+++ b/src/buildtool/build_engine/target_map/TARGETS
@@ -45,6 +45,7 @@
, ["src/buildtool/build_engine/base_maps", "rule_map"]
, ["src/buildtool/build_engine/base_maps", "source_map"]
, ["src/buildtool/build_engine/base_maps", "targets_file_map"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/multithreading", "async_map_consumer"]
, ["src/buildtool/storage", "storage"]
@@ -97,6 +98,7 @@
[ "configured_target"
, "result_map"
, ["src/buildtool/build_engine/analysed_target", "target"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/multithreading", "async_map_consumer"]
, ["@", "gsl", "", "gsl"]
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.cpp b/src/buildtool/build_engine/target_map/absent_target_map.cpp
index 27eb9e86..f72dc697 100644
--- a/src/buildtool/build_engine/target_map/absent_target_map.cpp
+++ b/src/buildtool/build_engine/target_map/absent_target_map.cpp
@@ -23,13 +23,15 @@
auto BuildMaps::Target::CreateAbsentTargetMap(
const gsl::not_null<ResultTargetMap*>& result_map,
gsl::not_null<RepositoryConfig*> const& repo_config,
+ gsl::not_null<Statistics*> const& local_stats,
std::size_t jobs) -> AbsentTargetMap {
#ifndef BOOTSTRAP_BUILD_TOOL
- auto target_reader = [result_map, repo_config](auto /*ts*/,
- auto setter,
- auto logger,
- auto /*subcaller*/,
- auto key) {
+ auto target_reader = [result_map, repo_config, local_stats](
+ auto /*ts*/,
+ auto setter,
+ auto logger,
+ auto /*subcaller*/,
+ auto key) {
// assumptions:
// - target with absent targets file requested
// - ServeApi correctly configured
@@ -137,7 +139,7 @@ auto BuildMaps::Target::CreateAbsentTargetMap(
info.ToString());
(*setter)(std::move(analysis_result));
- Statistics::Instance().IncrementExportsCachedCounter();
+ local_stats->IncrementExportsCachedCounter();
return;
}
(*logger)(fmt::format("Reading target entry for key {} failed",
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.hpp b/src/buildtool/build_engine/target_map/absent_target_map.hpp
index aa2b5b42..a00fc05d 100644
--- a/src/buildtool/build_engine/target_map/absent_target_map.hpp
+++ b/src/buildtool/build_engine/target_map/absent_target_map.hpp
@@ -19,6 +19,7 @@
#include "src/buildtool/build_engine/target_map/configured_target.hpp"
#include "src/buildtool/build_engine/target_map/result_map.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
namespace BuildMaps::Target {
@@ -26,6 +27,7 @@ using AbsentTargetMap = AsyncMapConsumer<ConfiguredTarget, AnalysedTargetPtr>;
auto CreateAbsentTargetMap(const gsl::not_null<ResultTargetMap*>&,
gsl::not_null<RepositoryConfig*> const& repo_config,
+ gsl::not_null<Statistics*> const& local_stats,
std::size_t jobs = 0) -> AbsentTargetMap;
} // namespace BuildMaps::Target
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.cpp b/src/buildtool/build_engine/target_map/built_in_rules.cpp
index d28a6ed9..2c90cc9d 100644
--- a/src/buildtool/build_engine/target_map/built_in_rules.cpp
+++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp
@@ -340,6 +340,7 @@ void FileGenRule(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
+ [[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -359,6 +360,7 @@ void SymlinkRule(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
+ [[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -487,6 +489,7 @@ void TreeRule(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
+ [[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -736,6 +739,7 @@ void InstallRule(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
+ [[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1322,6 +1326,7 @@ void GenericRule(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
+ [[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1400,6 +1405,7 @@ void ConfigureRule(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
[[maybe_unused]] const ActiveTargetCache& /*target_cache*/,
+ [[maybe_unused]] const gsl::not_null<Statistics*>& /*stats*/,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1541,6 +1547,7 @@ auto const kBuiltIns = std::unordered_map<
const BuildMaps::Target::ConfiguredTarget&,
const gsl::not_null<RepositoryConfig*>&,
const ActiveTargetCache&,
+ const gsl::not_null<Statistics*>&,
const BuildMaps::Target::TargetMap::SubCallerPtr&,
const BuildMaps::Target::TargetMap::SetterPtr&,
const BuildMaps::Target::TargetMap::LoggerPtr&,
@@ -1572,6 +1579,7 @@ auto HandleBuiltin(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
+ const gsl::not_null<Statistics*>& stats,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -1598,6 +1606,7 @@ auto HandleBuiltin(
key,
repo_config,
target_cache,
+ stats,
subcaller,
setter,
target_logger,
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.hpp b/src/buildtool/build_engine/target_map/built_in_rules.hpp
index e3e2f220..1eb6e086 100644
--- a/src/buildtool/build_engine/target_map/built_in_rules.hpp
+++ b/src/buildtool/build_engine/target_map/built_in_rules.hpp
@@ -21,6 +21,7 @@
#include "src/buildtool/build_engine/target_map/result_map.hpp"
#include "src/buildtool/build_engine/target_map/target_map.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/storage/target_cache.hpp"
namespace BuildMaps::Target {
@@ -30,6 +31,7 @@ auto HandleBuiltin(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
+ const gsl::not_null<Statistics*>& stats,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp
index c9aed0e3..29085716 100644
--- a/src/buildtool/build_engine/target_map/export.cpp
+++ b/src/buildtool/build_engine/target_map/export.cpp
@@ -98,6 +98,7 @@ void ExportRule(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
+ const gsl::not_null<Statistics*>& stats,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
@@ -134,7 +135,7 @@ void ExportRule(
#endif // BOOTSTRAP_BUILD_TOOL
if (not target_cache_value) {
- Statistics::Instance().IncrementExportsUncachedCounter();
+ stats->IncrementExportsUncachedCounter();
Logger::Log(LogLevel::Performance,
"Export target {} registered for caching: {}",
key.target.ToString(),
@@ -176,7 +177,7 @@ void ExportRule(
info.ToString());
(*setter)(std::move(analysis_result));
- Statistics::Instance().IncrementExportsCachedCounter();
+ stats->IncrementExportsCachedCounter();
return;
}
(*logger)(fmt::format("Reading target entry for key {} failed",
@@ -185,7 +186,7 @@ void ExportRule(
}
}
else {
- Statistics::Instance().IncrementExportsNotEligibleCounter();
+ stats->IncrementExportsNotEligibleCounter();
Logger::Log(LogLevel::Performance,
"Export target {} is not eligible for target caching",
key.target.ToString());
diff --git a/src/buildtool/build_engine/target_map/export.hpp b/src/buildtool/build_engine/target_map/export.hpp
index 7f470706..3f43796b 100644
--- a/src/buildtool/build_engine/target_map/export.hpp
+++ b/src/buildtool/build_engine/target_map/export.hpp
@@ -21,12 +21,14 @@
#include "src/buildtool/build_engine/target_map/result_map.hpp"
#include "src/buildtool/build_engine/target_map/target_map.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/storage/target_cache.hpp"
void ExportRule(const nlohmann::json& desc_json,
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
+ const gsl::not_null<Statistics*>& stats,
const BuildMaps::Target::TargetMap::SubCallerPtr& subcaller,
const BuildMaps::Target::TargetMap::SetterPtr& setter,
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
diff --git a/src/buildtool/build_engine/target_map/result_map.hpp b/src/buildtool/build_engine/target_map/result_map.hpp
index 6911bf02..dcc6577e 100644
--- a/src/buildtool/build_engine/target_map/result_map.hpp
+++ b/src/buildtool/build_engine/target_map/result_map.hpp
@@ -170,7 +170,9 @@ class ResultTargetMap {
}
template <bool kIncludeOrigins = false>
- [[nodiscard]] auto ToResult() const -> ResultType<kIncludeOrigins> {
+ [[nodiscard]] auto ToResult(gsl::not_null<Statistics const*> const& stats,
+ gsl::not_null<Progress*> const& progress) const
+ -> ResultType<kIncludeOrigins> {
ResultType<kIncludeOrigins> result{};
size_t na = 0;
size_t nb = 0;
@@ -184,7 +186,7 @@ class ResultTargetMap {
result.blobs.reserve(nb);
result.trees.reserve(nt);
- auto& origin_map = Progress::Instance().OriginMap();
+ auto& origin_map = progress->OriginMap();
origin_map.clear();
origin_map.reserve(na);
for (const auto& target : targets_) {
@@ -298,7 +300,7 @@ class ResultTargetMap {
});
result.actions.erase(lastaction, result.actions.end());
- int trees_traversed = Statistics::Instance().TreesAnalysedCounter();
+ int trees_traversed = stats->TreesAnalysedCounter();
if (trees_traversed > 0) {
Logger::Log(LogLevel::Performance,
"Analysed {} non-known source trees",
@@ -314,8 +316,10 @@ class ResultTargetMap {
}
template <bool kIncludeOrigins = false>
- [[nodiscard]] auto ToJson() const -> nlohmann::json {
- auto const result = ToResult<kIncludeOrigins>();
+ [[nodiscard]] auto ToJson(gsl::not_null<Statistics const*> const& stats,
+ gsl::not_null<Progress*> const& progress) const
+ -> nlohmann::json {
+ auto const result = ToResult<kIncludeOrigins>(stats, progress);
auto actions = nlohmann::json::object();
auto trees = nlohmann::json::object();
std::for_each(result.actions.begin(),
@@ -340,11 +344,15 @@ class ResultTargetMap {
}
template <bool kIncludeOrigins = true>
- auto ToFile(std::string const& graph_file, int indent = 2) const -> void {
+ auto ToFile(std::string const& graph_file,
+ gsl::not_null<Statistics const*> const& stats,
+ gsl::not_null<Progress*> const& progress,
+ int indent = 2) const -> void {
Logger::Log(
LogLevel::Info, "Dumping action graph to file {}.", graph_file);
std::ofstream os(graph_file);
- os << std::setw(indent) << ToJson<kIncludeOrigins>() << std::endl;
+ os << std::setw(indent) << ToJson<kIncludeOrigins>(stats, progress)
+ << std::endl;
}
void Clear(gsl::not_null<TaskSystem*> const& ts) {
diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp
index 4d28ac6a..aed6d93a 100644
--- a/src/buildtool/build_engine/target_map/target_map.cpp
+++ b/src/buildtool/build_engine/target_map/target_map.cpp
@@ -1238,6 +1238,7 @@ void withTargetsFile(
const BuildMaps::Target::ConfiguredTarget& key,
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
+ const gsl::not_null<Statistics*>& stats,
const nlohmann::json& targets_file,
const gsl::not_null<BuildMaps::Base::SourceTargetMap*>& source_target,
const gsl::not_null<BuildMaps::Base::UserRuleMap*>& rule_map,
@@ -1277,6 +1278,7 @@ void withTargetsFile(
key,
repo_config,
target_cache,
+ stats,
subcaller,
setter,
logger,
@@ -1457,7 +1459,8 @@ void TreeTarget(
const BuildMaps::Target::TargetMap::LoggerPtr& logger,
const gsl::not_null<BuildMaps::Target::ResultTargetMap*>& result_map,
const gsl::not_null<BuildMaps::Base::DirectoryEntriesMap*>&
- directory_entries) {
+ directory_entries,
+ const gsl::not_null<Statistics*>& stats) {
const auto& target = key.target.GetNamedTarget();
const auto dir_name = std::filesystem::path{target.module} / target.name;
auto module_ = BuildMaps::Base::ModuleName{target.repository, dir_name};
@@ -1465,7 +1468,7 @@ void TreeTarget(
directory_entries->ConsumeAfterKeysReady(
ts,
{module_},
- [setter, subcaller, target, key, result_map, logger, dir_name](
+ [setter, subcaller, target, key, result_map, logger, dir_name, stats](
auto values) {
// expected values.size() == 1
const auto& dir_entries = *values[0];
@@ -1495,7 +1498,7 @@ void TreeTarget(
"Source tree reference for non-known tree {}",
key.target.ToString());
});
- Statistics::Instance().IncrementTreesAnalysedCounter();
+ stats->IncrementTreesAnalysedCounter();
using BuildMaps::Target::ConfiguredTarget;
@@ -1660,6 +1663,7 @@ auto CreateTargetMap(
const gsl::not_null<ResultTargetMap*>& result_map,
const gsl::not_null<RepositoryConfig*>& repo_config,
const ActiveTargetCache& target_cache,
+ const gsl::not_null<Statistics*>& stats,
std::size_t jobs) -> TargetMap {
auto target_reader = [source_target_map,
targets_file_map,
@@ -1668,11 +1672,12 @@ auto CreateTargetMap(
absent_target_map,
result_map,
repo_config,
- target_cache](auto ts,
- auto setter,
- auto logger,
- auto subcaller,
- auto key) {
+ target_cache,
+ stats](auto ts,
+ auto setter,
+ auto logger,
+ auto subcaller,
+ auto key) {
if (key.target.IsAnonymousTarget()) {
withTargetNode(key,
repo_config,
@@ -1700,7 +1705,8 @@ auto CreateTargetMap(
setter,
wrapped_logger,
result_map,
- directory_entries_map);
+ directory_entries_map,
+ stats);
}
else if (key.target.GetNamedTarget().reference_t ==
BuildMaps::Base::ReferenceType::kFile) {
@@ -1808,6 +1814,7 @@ auto CreateTargetMap(
[key,
repo_config,
target_cache,
+ stats,
source_target_map,
rule_map,
ts,
@@ -1818,6 +1825,7 @@ auto CreateTargetMap(
withTargetsFile(key,
repo_config,
target_cache,
+ stats,
*values[0],
source_target_map,
rule_map,
diff --git a/src/buildtool/build_engine/target_map/target_map.hpp b/src/buildtool/build_engine/target_map/target_map.hpp
index 2832eb35..eda27b77 100644
--- a/src/buildtool/build_engine/target_map/target_map.hpp
+++ b/src/buildtool/build_engine/target_map/target_map.hpp
@@ -28,6 +28,7 @@
#include "src/buildtool/build_engine/target_map/configured_target.hpp"
#include "src/buildtool/build_engine/target_map/result_map.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
#include "src/buildtool/storage/target_cache.hpp"
@@ -44,6 +45,7 @@ auto CreateTargetMap(
const gsl::not_null<ResultTargetMap*>&,
const gsl::not_null<RepositoryConfig*>&,
const ActiveTargetCache&,
+ const gsl::not_null<Statistics*>& stats,
std::size_t jobs = 0) -> TargetMap;
// use explicit cast to std::function to allow template deduction when used
diff --git a/src/buildtool/common/statistics.hpp b/src/buildtool/common/statistics.hpp
index e8987d74..4022db15 100644
--- a/src/buildtool/common/statistics.hpp
+++ b/src/buildtool/common/statistics.hpp
@@ -19,11 +19,6 @@
class Statistics {
public:
- [[nodiscard]] static auto Instance() noexcept -> Statistics& {
- static Statistics instance{};
- return instance;
- }
-
void Reset() noexcept {
num_actions_queued_ = 0;
num_actions_executed_ = 0;
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index caf84b80..2220f15a 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -55,7 +55,9 @@ class ExecutorImpl {
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> const& dispatch_list,
std::chrono::milliseconds const& timeout,
- IExecutionAction::CacheFlag cache_flag)
+ IExecutionAction::CacheFlag cache_flag,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress)
-> std::optional<IExecutionResponse::Ptr> {
auto const& inputs = action->Dependencies();
auto const tree_action = action->Content().IsTreeAction();
@@ -95,8 +97,8 @@ class ExecutorImpl {
// do not count statistics for rebuilder fetching from cache
if (cache_flag != IExecutionAction::CacheFlag::FromCacheOnly) {
- Progress::Instance().TaskTracker().Start(action->Content().Id());
- Statistics::Instance().IncrementActionsQueuedCounter();
+ progress->TaskTracker().Start(action->Content().Id());
+ stats->IncrementActionsQueuedCounter();
}
auto alternative_api =
@@ -501,6 +503,8 @@ class ExecutorImpl {
Logger const& logger,
IExecutionResponse::Ptr const& response,
gsl::not_null<DependencyGraph::ActionNode const*> const& action,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
bool count_as_executed = false) -> bool {
logger.Emit(LogLevel::Trace, "finished execution");
@@ -511,12 +515,12 @@ class ExecutorImpl {
if (not count_as_executed and response->IsCached()) {
logger.Emit(LogLevel::Trace, " - served from cache");
- Statistics::Instance().IncrementActionsCachedCounter();
+ stats->IncrementActionsCachedCounter();
}
else {
- Statistics::Instance().IncrementActionsExecutedCounter();
+ stats->IncrementActionsExecutedCounter();
}
- Progress::Instance().TaskTracker().Stop(action->Content().Id());
+ progress->TaskTracker().Stop(action->Content().Id());
PrintInfo(logger, action->Command(), response);
bool should_fail_outputs = false;
@@ -535,7 +539,7 @@ class ExecutorImpl {
logger.Emit(LogLevel::Error,
"action returned non-zero exit code {}",
response->ExitCode());
- PrintError(logger, action);
+ PrintError(logger, action, progress);
return false;
}
}
@@ -556,7 +560,7 @@ class ExecutorImpl {
}
return message;
});
- PrintError(logger, action);
+ PrintError(logger, action, progress);
return false;
}
@@ -601,12 +605,12 @@ class ExecutorImpl {
void static PrintError(
Logger const& logger,
- gsl::not_null<DependencyGraph::ActionNode const*> const&
- action) noexcept {
+ gsl::not_null<DependencyGraph::ActionNode const*> const& action,
+ gsl::not_null<Progress*> const& progress) noexcept {
std::ostringstream msg{};
msg << "Failed to execute command ";
msg << nlohmann::json(action->Command()).dump();
- auto const& origin_map = Progress::Instance().OriginMap();
+ auto const& origin_map = progress->OriginMap();
auto origins = origin_map.find(action->Content().Id());
if (origins != origin_map.end() and !origins->second.empty()) {
msg << "\nrequested by";
@@ -680,12 +684,16 @@ class Executor {
std::map<std::string, std::string> properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> dispatch_list,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
std::chrono::milliseconds timeout = IExecutionAction::kDefaultTimeout)
: repo_config_{repo_config},
local_api_{local_api},
remote_api_{remote_api},
properties_{std::move(properties)},
dispatch_list_{std::move(dispatch_list)},
+ stats_{stats},
+ progress_{progress},
timeout_{timeout} {}
/// \brief Run an action in a blocking manner
@@ -704,10 +712,14 @@ class Executor {
Impl::MergeProperties(properties_, action->ExecutionProperties()),
dispatch_list_,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
- action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput);
+ action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput,
+ stats_,
+ progress_);
// check response and save digests of results
- return not response or Impl::ParseResponse(logger, *response, action);
+ return not response or
+ Impl::ParseResponse(
+ logger, *response, action, stats_, progress_);
}
/// \brief Check artifact is available to the CAS or upload it.
@@ -729,6 +741,8 @@ class Executor {
std::map<std::string, std::string> properties_;
std::vector<std::pair<std::map<std::string, std::string>, ServerAddress>>
dispatch_list_;
+ gsl::not_null<Statistics*> stats_;
+ gsl::not_null<Progress*> progress_;
std::chrono::milliseconds timeout_;
};
@@ -751,6 +765,8 @@ class Rebuilder {
std::map<std::string, std::string> properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> dispatch_list,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
std::chrono::milliseconds timeout = IExecutionAction::kDefaultTimeout)
: repo_config_{repo_config},
local_api_{local_api},
@@ -758,6 +774,8 @@ class Rebuilder {
api_cached_{api_cached},
properties_{std::move(properties)},
dispatch_list_{std::move(dispatch_list)},
+ stats_{stats},
+ progress_{progress},
timeout_{timeout} {}
[[nodiscard]] auto Process(
@@ -772,7 +790,9 @@ class Rebuilder {
Impl::MergeProperties(properties_, action->ExecutionProperties()),
dispatch_list_,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
- CF::PretendCached);
+ CF::PretendCached,
+ stats_,
+ progress_);
if (not response) {
return true; // action without response (e.g., tree action)
@@ -786,7 +806,9 @@ class Rebuilder {
Impl::MergeProperties(properties_, action->ExecutionProperties()),
dispatch_list_,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
- CF::FromCacheOnly);
+ CF::FromCacheOnly,
+ stats_,
+ progress_);
if (not response_cached) {
logger_cached.Emit(LogLevel::Error,
@@ -795,8 +817,12 @@ class Rebuilder {
}
DetectFlakyAction(*response, *response_cached, action->Content());
- return Impl::ParseResponse(
- logger, *response, action, /*count_as_executed=*/true);
+ return Impl::ParseResponse(logger,
+ *response,
+ action,
+ stats_,
+ progress_,
+ /*count_as_executed=*/true);
}
[[nodiscard]] auto Process(
@@ -827,6 +853,8 @@ class Rebuilder {
std::map<std::string, std::string> properties_;
std::vector<std::pair<std::map<std::string, std::string>, ServerAddress>>
dispatch_list_;
+ gsl::not_null<Statistics*> stats_;
+ gsl::not_null<Progress*> progress_;
std::chrono::milliseconds timeout_;
mutable std::mutex m_;
mutable std::vector<std::string> cache_misses_{};
@@ -842,7 +870,7 @@ class Rebuilder {
Action const& action) const noexcept {
if (response and response_cached and
response_cached->ActionDigest() == response->ActionDigest()) {
- Statistics::Instance().IncrementRebuiltActionComparedCounter();
+ stats_->IncrementRebuiltActionComparedCounter();
auto artifacts = response->Artifacts();
auto artifacts_cached = response_cached->Artifacts();
std::ostringstream msg{};
@@ -853,11 +881,10 @@ class Rebuilder {
}
}
if (msg.tellp() > 0) {
- Statistics::Instance().IncrementActionsFlakyCounter();
+ stats_->IncrementActionsFlakyCounter();
bool tainted = action.MayFail() or action.NoCache();
if (tainted) {
- Statistics::Instance()
- .IncrementActionsFlakyTaintedCounter();
+ stats_->IncrementActionsFlakyTaintedCounter();
}
Logger::Log(tainted ? LogLevel::Debug : LogLevel::Warning,
"{}",
@@ -865,7 +892,7 @@ class Rebuilder {
}
}
else {
- Statistics::Instance().IncrementRebuiltActionMissingCounter();
+ stats_->IncrementRebuiltActionMissingCounter();
std::unique_lock lock{m_};
cache_misses_.emplace_back(action.Id());
}
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
index 611ea3e0..b4604ef8 100644
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -75,11 +75,15 @@ class GraphTraverser {
gsl::not_null<RepositoryConfig*> const& repo_config,
std::map<std::string, std::string> platform_properties,
std::vector<std::pair<std::map<std::string, std::string>,
- ServerAddress>> dispatch_list)
+ ServerAddress>> dispatch_list,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress)
: clargs_{std::move(clargs)},
repo_config_{repo_config},
platform_properties_{std::move(platform_properties)},
dispatch_list_{std::move(dispatch_list)},
+ stats_{stats},
+ progress_{progress},
local_api_{CreateExecutionApi(std::nullopt,
std::make_optional(repo_config))},
remote_api_{CreateExecutionApi(RemoteExecutionConfig::RemoteAddress(),
@@ -92,11 +96,15 @@ class GraphTraverser {
std::map<std::string, std::string> platform_properties,
std::vector<std::pair<std::map<std::string, std::string>,
ServerAddress>> dispatch_list,
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress,
progress_reporter_t reporter)
: clargs_{std::move(clargs)},
repo_config_{repo_config},
platform_properties_{std::move(platform_properties)},
dispatch_list_{std::move(dispatch_list)},
+ stats_{stats},
+ progress_{progress},
local_api_{CreateExecutionApi(std::nullopt,
std::make_optional(repo_config))},
remote_api_{CreateExecutionApi(RemoteExecutionConfig::RemoteAddress(),
@@ -246,6 +254,8 @@ class GraphTraverser {
std::map<std::string, std::string> platform_properties_;
std::vector<std::pair<std::map<std::string, std::string>, ServerAddress>>
dispatch_list_;
+ gsl::not_null<Statistics*> stats_;
+ gsl::not_null<Progress*> progress_;
gsl::not_null<IExecutionApi::Ptr> const local_api_;
gsl::not_null<IExecutionApi::Ptr> const remote_api_;
progress_reporter_t reporter_;
@@ -368,6 +378,8 @@ class GraphTraverser {
&(*remote_api_),
platform_properties_,
dispatch_list_,
+ stats_,
+ progress_,
clargs_.build.timeout};
bool traversing{};
std::atomic<bool> done = false;
@@ -399,6 +411,8 @@ class GraphTraverser {
&(*api_cached),
platform_properties_,
dispatch_list_,
+ stats_,
+ progress_,
clargs_.build.timeout};
bool traversing{false};
std::atomic<bool> done = false;
@@ -444,20 +458,19 @@ class GraphTraverser {
}
void LogStatistics() const noexcept {
- auto const& stats = Statistics::Instance();
if (clargs_.rebuild) {
std::stringstream ss{};
- ss << stats.RebuiltActionComparedCounter()
+ ss << stats_->RebuiltActionComparedCounter()
<< " actions compared with cache";
- if (stats.ActionsFlakyCounter() > 0) {
- ss << ", " << stats.ActionsFlakyCounter()
+ if (stats_->ActionsFlakyCounter() > 0) {
+ ss << ", " << stats_->ActionsFlakyCounter()
<< " flaky actions found";
- ss << " (" << stats.ActionsFlakyTaintedCounter()
+ ss << " (" << stats_->ActionsFlakyTaintedCounter()
<< " of which tainted)";
}
- if (stats.RebuiltActionMissingCounter() > 0) {
+ if (stats_->RebuiltActionMissingCounter() > 0) {
ss << ", no cache entry found for "
- << stats.RebuiltActionMissingCounter() << " actions";
+ << stats_->RebuiltActionMissingCounter() << " actions";
}
ss << ".";
Logger::Log(LogLevel::Info, ss.str());
@@ -465,8 +478,8 @@ class GraphTraverser {
else {
Logger::Log(LogLevel::Info,
"Processed {} actions, {} cache hits.",
- stats.ActionsQueuedCounter(),
- stats.ActionsCachedCounter());
+ stats_->ActionsQueuedCounter(),
+ stats_->ActionsCachedCounter());
}
}
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS
index fd2adf7c..1919101c 100644
--- a/src/buildtool/main/TARGETS
+++ b/src/buildtool/main/TARGETS
@@ -4,11 +4,13 @@
, "name": ["just"]
, "srcs": ["main.cpp"]
, "private-deps":
- [ ["src/buildtool/common", "config"]
+ [ ["src/buildtool/common", "common"]
+ , ["src/buildtool/common", "config"]
, ["src/buildtool/storage", "storage"]
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/graph_traverser", "graph_traverser"]
, ["src/buildtool/logging", "logging"]
+ , ["src/buildtool/progress_reporting", "progress"]
, ["src/buildtool/progress_reporting", "progress_reporter"]
, ["src/buildtool/build_engine/target_map", "result_map"]
, ["src/buildtool/build_engine/target_map", "target_map"]
@@ -113,6 +115,7 @@
, "srcs": ["analyse.cpp"]
, "deps":
[ ["src/buildtool/common", "cli"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/build_engine/target_map", "configured_target"]
, ["src/buildtool/build_engine/target_map", "result_map"]
, ["src/buildtool/build_engine/analysed_target", "target"]
diff --git a/src/buildtool/main/analyse.cpp b/src/buildtool/main/analyse.cpp
index 6ea61de2..09973446 100644
--- a/src/buildtool/main/analyse.cpp
+++ b/src/buildtool/main/analyse.cpp
@@ -97,6 +97,7 @@ namespace Target = BuildMaps::Target;
gsl::not_null<Target::ResultTargetMap*> const& result_map,
gsl::not_null<RepositoryConfig*> const& repo_config,
ActiveTargetCache const& target_cache,
+ gsl::not_null<Statistics*> const& stats,
std::size_t jobs,
std::optional<std::string> const& request_action_input)
-> std::optional<AnalysisResult> {
@@ -112,7 +113,7 @@ namespace Target = BuildMaps::Target;
auto source_targets =
Base::CreateSourceTargetMap(&directory_entries, repo_config, jobs);
auto absent_target_map =
- Target::CreateAbsentTargetMap(result_map, repo_config, jobs);
+ Target::CreateAbsentTargetMap(result_map, repo_config, stats, jobs);
auto target_map = Target::CreateTargetMap(&source_targets,
&targets_file_map,
&rule_map,
@@ -121,6 +122,7 @@ namespace Target = BuildMaps::Target;
result_map,
repo_config,
target_cache,
+ stats,
jobs);
Logger::Log(LogLevel::Info, "Requested target is {}", id.ToString());
AnalysedTargetPtr target{};
diff --git a/src/buildtool/main/analyse.hpp b/src/buildtool/main/analyse.hpp
index a7e1cb08..c3b4917a 100644
--- a/src/buildtool/main/analyse.hpp
+++ b/src/buildtool/main/analyse.hpp
@@ -20,6 +20,7 @@
#include "src/buildtool/build_engine/target_map/result_map.hpp"
#include "src/buildtool/common/cli.hpp"
#include "src/buildtool/common/repository_config.hpp"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/storage/target_cache.hpp"
struct AnalysisResult {
@@ -33,6 +34,7 @@ struct AnalysisResult {
gsl::not_null<BuildMaps::Target::ResultTargetMap*> const& result_map,
gsl::not_null<RepositoryConfig*> const& repo_config,
ActiveTargetCache const& target_cache,
+ gsl::not_null<Statistics*> const& stats,
std::size_t jobs,
std::optional<std::string> const& request_action_input)
-> std::optional<AnalysisResult>;
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 642251c4..65f5278d 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -55,6 +55,7 @@
#include "src/buildtool/serve_api/serve_service/serve_server_implementation.hpp"
#include "src/buildtool/storage/garbage_collector.hpp"
#endif // BOOTSTRAP_BUILD_TOOL
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/logging/log_config.hpp"
#include "src/buildtool/logging/log_sink_cmdline.hpp"
#include "src/buildtool/logging/log_sink_file.hpp"
@@ -62,6 +63,7 @@
#include "src/buildtool/main/version.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/utils/cpp/concepts.hpp"
#include "src/utils/cpp/json.hpp"
@@ -913,6 +915,11 @@ auto main(int argc, char* argv[]) -> int {
? std::make_optional(std::move(arguments.rebuild))
: std::nullopt;
+ // statistics and progress instances; need to be kept alive
+ // used also in bootstrapped just
+ Statistics stats{};
+ Progress progress{};
+
#ifndef BOOTSTRAP_BUILD_TOOL
SetupRetryConfig(arguments.retry);
GraphTraverser const traverser{
@@ -923,7 +930,9 @@ auto main(int argc, char* argv[]) -> int {
&repo_config,
RemoteExecutionConfig::PlatformProperties(),
RemoteExecutionConfig::DispatchList(),
- ProgressReporter::Reporter()};
+ &stats,
+ &progress,
+ ProgressReporter::Reporter(&stats, &progress)};
if (arguments.cmd == SubCommand::kInstallCas) {
if (not repo_config.SetGitCAS(StorageConfig::GitRoot())) {
@@ -999,11 +1008,13 @@ auto main(int argc, char* argv[]) -> int {
&result_map,
&repo_config,
Storage::Instance().TargetCache(),
+ &stats,
arguments.common.jobs,
arguments.analysis.request_action_input);
if (result) {
if (arguments.analysis.graph_file) {
- result_map.ToFile(*arguments.analysis.graph_file);
+ result_map.ToFile(
+ *arguments.analysis.graph_file, &stats, &progress);
}
auto const [artifacts, runfiles] =
ReadOutputArtifacts(result->target);
@@ -1028,11 +1039,10 @@ auto main(int argc, char* argv[]) -> int {
"Analysed target {}",
result->id.ToString());
- auto const& stat = Statistics::Instance();
{
- auto cached = stat.ExportsCachedCounter();
- auto uncached = stat.ExportsUncachedCounter();
- auto not_eligible = stat.ExportsNotEligibleCounter();
+ auto cached = stats.ExportsCachedCounter();
+ auto uncached = stats.ExportsUncachedCounter();
+ auto not_eligible = stats.ExportsNotEligibleCounter();
Logger::Log(cached + uncached + not_eligible > 0
? LogLevel::Info
: LogLevel::Debug,
@@ -1044,7 +1054,8 @@ auto main(int argc, char* argv[]) -> int {
}
ReportTaintedness(*result);
- auto const& [actions, blobs, trees] = result_map.ToResult();
+ auto const& [actions, blobs, trees] =
+ result_map.ToResult(&stats, &progress);
// collect cache targets and artifacts for target-level caching
auto const cache_targets = result_map.CacheTargets();
diff --git a/src/buildtool/progress_reporting/TARGETS b/src/buildtool/progress_reporting/TARGETS
index 45c3db1c..6a00bcdc 100644
--- a/src/buildtool/progress_reporting/TARGETS
+++ b/src/buildtool/progress_reporting/TARGETS
@@ -24,14 +24,14 @@
, "hdrs": ["progress_reporter.hpp"]
, "srcs": ["progress_reporter.cpp"]
, "stage": ["src", "buildtool", "progress_reporting"]
- , "deps": ["base_progress_reporter"]
- , "private-deps":
- [ "progress"
- , ["@", "fmt", "", "fmt"]
+ , "deps":
+ [ "base_progress_reporter"
+ , "progress"
, ["@", "gsl", "", "gsl"]
, ["src/buildtool/common", "common"]
- , ["src/buildtool/logging", "logging"]
]
+ , "private-deps":
+ [["@", "fmt", "", "fmt"], ["src/buildtool/logging", "logging"]]
}
, "base_progress_reporter":
{ "type": ["@", "rules", "CC", "library"]
diff --git a/src/buildtool/progress_reporting/progress.hpp b/src/buildtool/progress_reporting/progress.hpp
index 43cdc7cc..d9b3aa8e 100644
--- a/src/buildtool/progress_reporting/progress.hpp
+++ b/src/buildtool/progress_reporting/progress.hpp
@@ -26,11 +26,6 @@
class Progress {
public:
- [[nodiscard]] static auto Instance() noexcept -> Progress& {
- static Progress instance{};
- return instance;
- }
-
[[nodiscard]] auto TaskTracker() noexcept -> TaskTracker& {
return task_tracker_;
}
diff --git a/src/buildtool/progress_reporting/progress_reporter.cpp b/src/buildtool/progress_reporting/progress_reporter.cpp
index 86ec0c0e..27960172 100644
--- a/src/buildtool/progress_reporting/progress_reporter.cpp
+++ b/src/buildtool/progress_reporting/progress_reporter.cpp
@@ -17,25 +17,23 @@
#include <string>
#include "fmt/core.h"
-#include "gsl/gsl"
-#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
-#include "src/buildtool/progress_reporting/progress.hpp"
-auto ProgressReporter::Reporter() noexcept -> progress_reporter_t {
- return BaseProgressReporter::Reporter([]() {
- int total = gsl::narrow<int>(Progress::Instance().OriginMap().size());
+auto ProgressReporter::Reporter(
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress) noexcept -> progress_reporter_t {
+ return BaseProgressReporter::Reporter([stats, progress]() {
+ int total = gsl::narrow<int>(progress->OriginMap().size());
// Note: order matters; queued has to be queried last
- auto const& sample = Progress::Instance().TaskTracker().Sample();
- auto const& stats = Statistics::Instance();
- int cached = stats.ActionsCachedCounter();
- int run = stats.ActionsExecutedCounter();
- int queued = stats.ActionsQueuedCounter();
+ auto const& sample = progress->TaskTracker().Sample();
+ int cached = stats->ActionsCachedCounter();
+ int run = stats->ActionsExecutedCounter();
+ int queued = stats->ActionsQueuedCounter();
int active = queued - run - cached;
std::string now_msg;
if (active > 0 and !sample.empty()) {
- auto const& origin_map = Progress::Instance().OriginMap();
+ auto const& origin_map = progress->OriginMap();
auto origins = origin_map.find(sample);
if (origins != origin_map.end() and !origins->second.empty()) {
auto const& origin = origins->second[0];
diff --git a/src/buildtool/progress_reporting/progress_reporter.hpp b/src/buildtool/progress_reporting/progress_reporter.hpp
index 5323578f..1c4206de 100644
--- a/src/buildtool/progress_reporting/progress_reporter.hpp
+++ b/src/buildtool/progress_reporting/progress_reporter.hpp
@@ -15,11 +15,17 @@
#ifndef INCLUDED_SRC_BUILDTOOL_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
#define INCLUDED_SRC_BUILDTOOL_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
+#include "gsl/gsl"
+#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/progress_reporting/base_progress_reporter.hpp"
+#include "src/buildtool/progress_reporting/progress.hpp"
class ProgressReporter {
public:
- [[nodiscard]] static auto Reporter() noexcept -> progress_reporter_t;
+ [[nodiscard]] static auto Reporter(
+ gsl::not_null<Statistics*> const& stats,
+ gsl::not_null<Progress*> const& progress) noexcept
+ -> progress_reporter_t;
};
#endif // INCLUDED_SRC_BUILDTOOL_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 97b75b53..202335d9 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -401,11 +401,17 @@ auto TargetService::ServeTarget(
auto configured_target = BuildMaps::Target::ConfiguredTarget{
.target = std::move(*entity), .config = std::move(config)};
+ // setup progress reporting; these instances need to be kept alive for
+ // graph traversal, analysis, and build
+ Statistics stats;
+ Progress progress;
+
// analyse the configured target
auto result = AnalyseTarget(configured_target,
&result_map,
&repository_config,
*tc,
+ &stats,
RemoteServeConfig::Jobs(),
std::nullopt /*request_action_input*/);
@@ -420,7 +426,8 @@ auto TargetService::ServeTarget(
auto const [artifacts, runfiles] = ReadOutputArtifacts(result->target);
// get the result map outputs
- auto const& [actions, blobs, trees] = result_map.ToResult();
+ auto const& [actions, blobs, trees] =
+ result_map.ToResult(&stats, &progress);
// collect cache targets and artifacts for target-level caching
auto const cache_targets = result_map.CacheTargets();
@@ -443,11 +450,14 @@ auto TargetService::ServeTarget(
traverser_args.build.timeout = RemoteServeConfig::ActionTimeout();
traverser_args.stage = std::nullopt;
traverser_args.rebuild = std::nullopt;
- GraphTraverser const traverser{std::move(traverser_args),
- &repository_config,
- std::move(platform_properties),
- std::move(dispatch_list),
- ProgressReporter::Reporter()};
+ GraphTraverser const traverser{
+ std::move(traverser_args),
+ &repository_config,
+ std::move(platform_properties),
+ std::move(dispatch_list),
+ &stats,
+ &progress,
+ ProgressReporter::Reporter(&stats, &progress)};
// perform build
auto build_result = traverser.BuildAndStage(
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++);
}