Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use_repo(
# LLVM toolchain (used for clang-format and clang-tidy)
bazel_dep(name = "toolchains_llvm", version = "1.4.0", dev_dependency = True)

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
llvm.toolchain(
llvm_version = "15.0.2",
stdlib = {"linux-x86_64": "stdc++"},
Expand Down
174 changes: 173 additions & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions score/launch_manager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ alias(
actual = "//score/launch_manager/src/lifecycle_client:applicationcontext_mock",
)

alias(
cc_library(
name = "lifecycle_mock_cc",
actual = "//score/launch_manager/src/lifecycle_client:lifecycle_mock",
testonly = True,
deps = [
"//score/launch_manager/src/lifecycle_client:lifecycle_mock",
"//score/launch_manager/src/lifecycle_client:report_running_mock",
],
)

alias(
Expand Down
11 changes: 11 additions & 0 deletions score/launch_manager/src/lifecycle_client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ cc_library(
visibility = ["//score/launch_manager:__subpackages__"],
deps = [
":applicationcontext_mock",
":lifecyclemanager",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really correct to add the lifecylemanager here?
Now this target contains both, the lifecyclemanagermock.cpp and the actual lifecyclemanager implementation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's intentional. LifeCycleManagerMock inherits from the concrete LifeCycleManager class. Without :lifecyclemanager in its deps, the vtable symbols for the base class are undefined when building lifecycle_mock as a shared library under --no-allow-shlib-undefined.
Adding :lifecyclemanager provides the vtable — this is the minimum fix to make the linker happy. The mock .cpp itself remains unchanged; it just needs the base class compiled in.

"@googletest//:gtest",
"@score_baselibs//score/os/utils:signal",
"@score_baselibs//score/os/utils/mocklib:signal_mock",
Expand All @@ -209,6 +210,16 @@ cc_library(
],
)

cc_test(
name = "lifecycle_mocks_UT",
srcs = ["src/lifecycle_mocks_UT.cpp"],
deps = [
":runapplication",
"//score/launch_manager:lifecycle_mock_cc",
"@googletest//:gtest_main",
],
)

cc_test(
name = "runapplication_UT",
srcs = ["src/runapplication_UT.cpp"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,38 @@ score::mw::lifecycle::ApplicationContextMock::~ApplicationContextMock()
}

score::mw::lifecycle::ApplicationContext::ApplicationContext(const std::int32_t argc, const char* const argv[])
: m_args(argv, argv + argc), m_app_path(argc > 0 ? std::string{argv[0]} : std::string{})
{
auto& constructor_callback = GetConstructorCallback();
constructor_callback(argc, argv);
if (constructor_callback)
{
constructor_callback(argc, argv);
}
}

const std::vector<std::string>& score::mw::lifecycle::ApplicationContext::get_arguments() const noexcept
{
auto& get_arguments_callback = GetGetArgumentsCallback();
return get_arguments_callback();
if (get_arguments_callback)
{
return get_arguments_callback();
}
return m_args;
}

std::string score::mw::lifecycle::ApplicationContext::get_argument(const std::string_view flag) const noexcept
{
auto& get_argument_callback = GetGetArgumentCallback();
return get_argument_callback(flag);
if (get_argument_callback)
{
return get_argument_callback(flag);
}
for (auto it = m_args.cbegin(); it != m_args.cend(); ++it)
{
if (it->rfind(flag, 0) == 0)
{
return *it;
}
}
return {};
}
Loading
Loading