-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Conversation
@llvm/pr-subscribers-lldb Author: Vy Nguyen (oontvoo) ChangesFull diff: https://github.com/llvm/llvm-project/pull/131203.diff 1 Files Affected:
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; });
|
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.