Skip to content

[LLDB][NFC]Refactor common test setup into SetUp method #131203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2025
Merged
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
31 changes: 12 additions & 19 deletions lldb/unittests/Core/TelemetryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ using namespace lldb_private::telemetry;
class TelemetryTest : public testing::Test {
public:
lldb_private::SubsystemRAII<lldb_private::FakePlugin> subsystems;
std::vector<std::unique_ptr<::llvm::telemetry::TelemetryInfo>>
received_entries;

void SetUp() override {
auto *ins = lldb_private::telemetry::TelemetryManager::GetInstance();
ASSERT_NE(ins, nullptr);

ins->addDestination(
std::make_unique<lldb_private::TestDestination>(&received_entries));
}
};

#if LLVM_ENABLE_TELEMETRY
Expand All @@ -90,17 +100,8 @@ class TelemetryTest : public testing::Test {
#endif

TELEMETRY_TEST(TelemetryTest, PluginTest) {
// This would have been called by the plugin reg in a "real" plugin
// For tests, we just call it directly.
lldb_private::FakePlugin::Initialize();

auto *ins = lldb_private::telemetry::TelemetryManager::GetInstance();
ASSERT_NE(ins, nullptr);

std::vector<std::unique_ptr<::llvm::telemetry::TelemetryInfo>>
received_entries;
ins->addDestination(
std::make_unique<lldb_private::TestDestination>(&received_entries));
lldb_private::telemetry::TelemetryManager *ins =
lldb_private::telemetry::TelemetryManager::GetInstance();

lldb_private::FakeTelemetryInfo entry;
entry.msg = "";
Expand All @@ -115,14 +116,6 @@ TELEMETRY_TEST(TelemetryTest, PluginTest) {
}

TELEMETRY_TEST(TelemetryTest, ScopedDispatcherTest) {
lldb_private::FakePlugin::Initialize();
auto *ins = TelemetryManager::GetInstance();
ASSERT_NE(ins, nullptr);
std::vector<std::unique_ptr<::llvm::telemetry::TelemetryInfo>>
received_entries;
ins->addDestination(
std::make_unique<lldb_private::TestDestination>(&received_entries));

{
ScopedDispatcher<lldb_private::FakeTelemetryInfo> helper(
[](lldb_private::FakeTelemetryInfo *info) { info->num = 0; });
Expand Down