diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-03-07 15:44:28 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-03-11 15:59:05 +0100 |
commit | 5f6ff55e97104e46c1b5c2c94b39ea0fca35ca7c (patch) | |
tree | 9a8a70d311f2c55c20f426258455f9fb3037328a /test/buildtool/execution_engine/executor/executor.test.cpp | |
parent | b885deebf9fc02b9f1e849d91de93fadcfb71a73 (diff) | |
download | justbuild-5f6ff55e97104e46c1b5c2c94b39ea0fca35ca7c.tar.gz |
just: Replace singletons for progress tracking and statistics...
...with regular instances that have controlled life-times.
This avoids race conditions in tracking and reporting the results
of analysis and build, as the serve endpoint can orchestrate
multiple builds at the same time asynchronously. As a bonus
side-effect this also ensures the correctness of the progress
reporting per orchestrated build.
Diffstat (limited to 'test/buildtool/execution_engine/executor/executor.test.cpp')
-rw-r--r-- | test/buildtool/execution_engine/executor/executor.test.cpp | 47 |
1 files changed, 38 insertions, 9 deletions
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))); |