Skip to content
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

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

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

oontvoo
Copy link
Member

@oontvoo oontvoo commented Mar 13, 2025

No description provided.

@oontvoo oontvoo requested a review from JDevlieghere as a code owner March 13, 2025 19:58
@llvmbot llvmbot added the lldb label Mar 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2025

@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/131203.diff

1 Files Affected:

  • (modified) lldb/unittests/Core/TelemetryTest.cpp (+16-19)
diff --git a/lldb/unittests/Core/TelemetryTest.cpp b/lldb/unittests/Core/TelemetryTest.cpp
index 72db8c17f09ea..f7dab948faba1 100644
--- a/lldb/unittests/Core/TelemetryTest.cpp
+++ b/lldb/unittests/Core/TelemetryTest.cpp
@@ -81,6 +81,20 @@ 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 {
+    // This would have been called by the plugin reg in a "real" pluging
+    // For tests, we just call it directly.
+    lldb_private::FakePlugin::Initialize();
+
+    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
@@ -90,17 +104,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 = "";
@@ -115,14 +120,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; });

@oontvoo oontvoo requested a review from labath March 14, 2025 15:24
void SetUp() override {
// This would have been called by the plugin reg in a "real" pluging
// For tests, we just call it directly.
lldb_private::FakePlugin::Initialize();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is needed anymore with the SubsystemRAII above?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@oontvoo oontvoo merged commit ca87823 into llvm:main Mar 18, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants