Skip to content

Commit c265467

Browse files
committed
define test-macro helper to skip tests when telemetry is disabled
1 parent 36ffad7 commit c265467

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

lldb/unittests/Core/TelemetryTest.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ class FakePlugin : public telemetry::TelemetryManager {
6666

6767
} // namespace lldb_private
6868

69-
TEST(TelemetryTest, PluginTest) {
69+
#if LLVM_ENABLE_TELEMETRY
70+
#define TELEMETRY_TEST(suite, test) TEST(suite, test)
71+
#else
72+
#define TELEMETRY_TEST(suite, test) TEST(DISABLED_##suite, test)
73+
#endif
74+
75+
76+
TELEMETRY_TEST(TelemetryTest, PluginTest) {
7077
// This would have been called by the plugin reg in a "real" plugin
7178
// For tests, we just call it directly.
7279
lldb_private::FakePlugin::Initialize();

llvm/unittests/Telemetry/TelemetryTest.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,14 @@ std::shared_ptr<Config> getTelemetryConfig(const TestContext &Ctxt) {
212212
return std::make_shared<Config>(false);
213213
}
214214

215-
TEST(TelemetryTest, TelemetryDisabled) {
216-
if (!Config::BuildTimeEnableTelemetry)
217-
GTEST_SKIP();
215+
#if LLVM_ENABLE_TELEMETRY
216+
#define TELEMETRY_TEST(suite, test) TEST(suite, test)
217+
#else
218+
#define TELEMETRY_TEST(suite, test) TEST(DISABLED_##suite, test)
219+
#endif
220+
221+
222+
TELEMETRY_TEST(TelemetryTest, TelemetryDisabled) {
218223
TestContext Context;
219224
Context.HasVendorPlugin = false;
220225

@@ -223,9 +228,7 @@ TEST(TelemetryTest, TelemetryDisabled) {
223228
EXPECT_EQ(nullptr, Manager);
224229
}
225230

226-
TEST(TelemetryTest, TelemetryEnabled) {
227-
if (!Config::BuildTimeEnableTelemetry)
228-
GTEST_SKIP();
231+
TELEMETRY_TEST(TelemetryTest, TelemetryEnabled) {
229232
const std::string ToolName = "TelemetryTestTool";
230233

231234
// Preset some params.

0 commit comments

Comments
 (0)