From 5f6ff55e97104e46c1b5c2c94b39ea0fca35ca7c Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 7 Mar 2024 15:44:28 +0100 Subject: 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. --- .../execution_engine/executor/executor.test.cpp | 47 +++++++++++++++++----- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'test/buildtool/execution_engine/executor/executor.test.cpp') 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))); -- cgit v1.2.3