Skip to content

Commit f3f2d84

Browse files
committed
Use static var to check progress total
Use the changes implemented in #79912 to use a static variable from `Progress` to ensure that the report was created with a non-deterministic total.
1 parent bb71954 commit f3f2d84

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

lldb/unittests/Core/ProgressReportTest.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,44 @@ using namespace lldb;
2121
using namespace lldb_private;
2222

2323
class ProgressReportTest : public ::testing::Test {
24-
SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
25-
26-
// The debugger's initialization function can't be called with no arguments
27-
// so calling it using SubsystemRAII will cause the test build to fail as
28-
// SubsystemRAII will call Initialize with no arguments. As such we set it up
29-
// here the usual way.
30-
void SetUp() override { Debugger::Initialize(nullptr); }
31-
void TearDown() override { Debugger::Terminate(); }
24+
SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
25+
26+
// The debugger's initialization function can't be called with no arguments
27+
// so calling it using SubsystemRAII will cause the test build to fail as
28+
// SubsystemRAII will call Initialize with no arguments. As such we set it up
29+
// here the usual way.
30+
void SetUp() override { Debugger::Initialize(nullptr); }
31+
void TearDown() override { Debugger::Terminate(); }
3232
};
3333

3434
TEST_F(ProgressReportTest, TestReportCreation) {
3535
std::chrono::milliseconds timeout(100);
36-
const unsigned long long NO_TOTAL = 1;
3736

38-
// Set up the debugger, make sure that was done properly
37+
// Set up the debugger, make sure that was done properly.
3938
ArchSpec arch("x86_64-apple-macosx-");
4039
Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
4140

4241
DebuggerSP debugger_sp = Debugger::CreateInstance();
4342
ASSERT_TRUE(debugger_sp);
4443

45-
// Get the debugger's broadcaster
44+
// Get the debugger's broadcaster.
4645
Broadcaster &broadcaster = debugger_sp->GetBroadcaster();
4746

4847
// Create a listener, make sure it can receive events and that it's
49-
// listening to the correct broadcast bit
48+
// listening to the correct broadcast bit.
5049
ListenerSP listener_sp = Listener::MakeListener("progress-listener");
5150

5251
listener_sp->StartListeningForEvents(&broadcaster,
5352
Debugger::eBroadcastBitProgress);
5453
EXPECT_TRUE(
55-
broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
54+
broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
5655

5756
EventSP event_sp;
5857
const ProgressEventData *data;
5958

60-
// Scope this for RAII on the progress objects
59+
// Scope this for RAII on the progress objects.
6160
// Create progress reports and check that their respective events for having
62-
// started are broadcasted
61+
// started and ended are broadcasted.
6362
{
6463
Progress progress1("Progress report 1", "Starting report 1");
6564
Progress progress2("Progress report 2", "Starting report 2");
@@ -76,7 +75,7 @@ TEST_F(ProgressReportTest, TestReportCreation) {
7675
ASSERT_EQ(data->GetDetails(), "Starting report 1");
7776
ASSERT_FALSE(data->IsFinite());
7877
ASSERT_FALSE(data->GetCompleted());
79-
ASSERT_EQ(data->GetTotal(), NO_TOTAL);
78+
ASSERT_EQ(data->GetTotal(), Progress::kNonDeterministicTotal);
8079
ASSERT_EQ(data->GetMessage(), "Progress report 1: Starting report 1");
8180

8281
EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
@@ -85,20 +84,20 @@ TEST_F(ProgressReportTest, TestReportCreation) {
8584
ASSERT_EQ(data->GetDetails(), "Starting report 2");
8685
ASSERT_FALSE(data->IsFinite());
8786
ASSERT_FALSE(data->GetCompleted());
88-
ASSERT_EQ(data->GetTotal(), NO_TOTAL);
87+
ASSERT_EQ(data->GetTotal(), Progress::kNonDeterministicTotal);
8988
ASSERT_EQ(data->GetMessage(), "Progress report 2: Starting report 2");
9089

9190
EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
9291
data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
9392
ASSERT_EQ(data->GetDetails(), "Starting report 3");
9493
ASSERT_FALSE(data->IsFinite());
9594
ASSERT_FALSE(data->GetCompleted());
96-
ASSERT_EQ(data->GetTotal(), NO_TOTAL);
95+
ASSERT_EQ(data->GetTotal(), Progress::kNonDeterministicTotal);
9796
ASSERT_EQ(data->GetMessage(), "Progress report 3: Starting report 3");
9897

9998
// Progress report objects should be destroyed at this point so
10099
// get each report from the queue and check that they've been
101-
// destroyed in reverse order
100+
// destroyed in reverse order.
102101
EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
103102
data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
104103

0 commit comments

Comments
 (0)