diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-25 14:35:28 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-30 12:10:06 +0200 |
commit | 69f56ad981da59f026c83b321522ad68283934c5 (patch) | |
tree | d85218053bb97bf623b541d9bc98fc9a3b0cbb44 /test/buildtool/execution_engine/executor | |
parent | ab0e0b86fff94bed224f894be6b555272857e336 (diff) | |
download | justbuild-69f56ad981da59f026c83b321522ad68283934c5.tar.gz |
Pass LocalContext to LocalApi
The context is passed by not_null const pointer to avoid binding to
temporaries. The LocalApi also stores the context as const ref for
further access and passing it to LocalAction.
Diffstat (limited to 'test/buildtool/execution_engine/executor')
-rw-r--r-- | test/buildtool/execution_engine/executor/TARGETS | 1 | ||||
-rw-r--r-- | test/buildtool/execution_engine/executor/executor_api_local.test.cpp | 59 |
2 files changed, 37 insertions, 23 deletions
diff --git a/test/buildtool/execution_engine/executor/TARGETS b/test/buildtool/execution_engine/executor/TARGETS index c5a9b810..58a6dbdb 100644 --- a/test/buildtool/execution_engine/executor/TARGETS +++ b/test/buildtool/execution_engine/executor/TARGETS @@ -52,6 +52,7 @@ , ["@", "src", "src/buildtool/common", "common"] , ["@", "src", "src/buildtool/common", "config"] , ["@", "src", "src/buildtool/execution_api/local", "config"] + , ["@", "src", "src/buildtool/execution_api/local", "context"] , ["@", "src", "src/buildtool/execution_api/local", "local"] , ["@", "src", "src/buildtool/execution_api/remote", "config"] , ["@", "src", "src/buildtool/execution_engine/executor", "executor"] 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 4fee58da..2e1dfaa2 100644 --- a/test/buildtool/execution_engine/executor/executor_api_local.test.cpp +++ b/test/buildtool/execution_engine/executor/executor_api_local.test.cpp @@ -18,6 +18,7 @@ #include "src/buildtool/common/repository_config.hpp" #include "src/buildtool/common/statistics.hpp" #include "src/buildtool/execution_api/local/config.hpp" +#include "src/buildtool/execution_api/local/context.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" @@ -31,20 +32,29 @@ TEST_CASE("Executor<LocalApi>: Upload blob", "[executor]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - LocalExecutionConfig local_exec_config{}; + + // pack the local context instances to be passed to LocalApi + LocalContext const local_context{.exec_config = &local_exec_config, + .storage_config = &storage_config.Get(), + .storage = &storage}; + RepositoryConfig repo_config{}; TestBlobUpload(&repo_config, [&] { - return std::make_unique<LocalApi>( - &storage_config.Get(), &storage, &local_exec_config, &repo_config); + return std::make_unique<LocalApi>(&local_context, &repo_config); }); } TEST_CASE("Executor<LocalApi>: Compile hello world", "[executor]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - LocalExecutionConfig local_exec_config{}; + + // pack the local context instances to be passed to LocalApi + LocalContext const local_context{.exec_config = &local_exec_config, + .storage_config = &storage_config.Get(), + .storage = &storage}; + RepositoryConfig repo_config{}; Statistics stats{}; Progress progress{}; @@ -55,10 +65,7 @@ TEST_CASE("Executor<LocalApi>: Compile hello world", "[executor]") { &stats, &progress, [&] { - return std::make_unique<LocalApi>(&storage_config.Get(), - &storage, - &local_exec_config, - &repo_config); + return std::make_unique<LocalApi>(&local_context, &repo_config); }, &*auth_config); } @@ -66,8 +73,13 @@ TEST_CASE("Executor<LocalApi>: Compile hello world", "[executor]") { TEST_CASE("Executor<LocalApi>: Compile greeter", "[executor]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - LocalExecutionConfig local_exec_config{}; + + // pack the local context instances to be passed to LocalApi + LocalContext const local_context{.exec_config = &local_exec_config, + .storage_config = &storage_config.Get(), + .storage = &storage}; + RepositoryConfig repo_config{}; Statistics stats{}; Progress progress{}; @@ -78,10 +90,7 @@ TEST_CASE("Executor<LocalApi>: Compile greeter", "[executor]") { &stats, &progress, [&] { - return std::make_unique<LocalApi>(&storage_config.Get(), - &storage, - &local_exec_config, - &repo_config); + return std::make_unique<LocalApi>(&local_context, &repo_config); }, &*auth_config); } @@ -89,8 +98,13 @@ TEST_CASE("Executor<LocalApi>: Compile greeter", "[executor]") { TEST_CASE("Executor<LocalApi>: Upload and download trees", "[executor]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - LocalExecutionConfig local_exec_config{}; + + // pack the local context instances to be passed to LocalApi + LocalContext const local_context{.exec_config = &local_exec_config, + .storage_config = &storage_config.Get(), + .storage = &storage}; + RepositoryConfig repo_config{}; Statistics stats{}; Progress progress{}; @@ -101,10 +115,7 @@ TEST_CASE("Executor<LocalApi>: Upload and download trees", "[executor]") { &stats, &progress, [&] { - return std::make_unique<LocalApi>(&storage_config.Get(), - &storage, - &local_exec_config, - &repo_config); + return std::make_unique<LocalApi>(&local_context, &repo_config); }, &*auth_config); } @@ -112,8 +123,13 @@ TEST_CASE("Executor<LocalApi>: Upload and download trees", "[executor]") { TEST_CASE("Executor<LocalApi>: Retrieve output directories", "[executor]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - LocalExecutionConfig local_exec_config{}; + + // pack the local context instances to be passed to LocalApi + LocalContext const local_context{.exec_config = &local_exec_config, + .storage_config = &storage_config.Get(), + .storage = &storage}; + RepositoryConfig repo_config{}; Statistics stats{}; Progress progress{}; @@ -124,10 +140,7 @@ TEST_CASE("Executor<LocalApi>: Retrieve output directories", "[executor]") { &stats, &progress, [&] { - return std::make_unique<LocalApi>(&storage_config.Get(), - &storage, - &local_exec_config, - &repo_config); + return std::make_unique<LocalApi>(&local_context, &repo_config); }, &*auth_config); } |