Index: unittests/Support/DebugCounterTest.cpp =================================================================== --- unittests/Support/DebugCounterTest.cpp +++ unittests/Support/DebugCounterTest.cpp @@ -18,6 +18,14 @@ "Counter used for unit test"); TEST(DebugCounterTest, CounterCheck) { + // Unfortunately, the CommandLineTest.GetCommandLineArguments test would + // unregister the global counter above. + if (!DebugCounter::instance().getCounterId("test-counter")) { + const_cast(TestCounter) = + DebugCounter::instance().registerCounter("test-counter", + "Counter used for unit test"); + } + EXPECT_FALSE(DebugCounter::isCounterSet(TestCounter)); auto DC = &DebugCounter::instance();