From 6bfc25ddf95e9e73edddff71dc79df36614351c7 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 27 Jul 2026 17:05:59 +0100 Subject: [PATCH] fix(test): brace assertion bodies gcc reads as a dangling else The gcc debug-coverage job rejected an unbraced `if` whose body is a GTest assertion: EXPECT_EQ expands to an if/else, so the outer `if` leaves an else that could bind either way, and -Werror=dangling-else refuses it. clang does not warn, which is why only that one job failed. Braced the span-names case that failed, then swept every test file this branch touches for the same shape and braced the two others found, so the next gcc run does not fail on the next one down the list. Co-Authored-By: Claude Opus 5 (1M context) --- src/test/core/JobQueue_test.cpp | 2 ++ src/test/overlay/TMGetObjectByHash_test.cpp | 2 ++ src/tests/libxrpl/telemetry/LedgerSpanNames.cpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/test/core/JobQueue_test.cpp b/src/test/core/JobQueue_test.cpp index 47c0995cde..c5ebfb3f82 100644 --- a/src/test/core/JobQueue_test.cpp +++ b/src/test/core/JobQueue_test.cpp @@ -539,7 +539,9 @@ class JobQueue_test : public beast::unit_test::Suite // Every one of these must defer: the limit is already reached. int const extra = 4; for (int i = 0; i < extra; ++i) + { BEAST_EXPECT(fixture.queue.addJob(JtPack, "GaugeDefer", blockingJob)); + } // Exact values, not bounds: `running` equals the type's limit and // `deferred` equals the number of submissions beyond it. Both are diff --git a/src/test/overlay/TMGetObjectByHash_test.cpp b/src/test/overlay/TMGetObjectByHash_test.cpp index b0e3b70dfa..c6ac3222af 100644 --- a/src/test/overlay/TMGetObjectByHash_test.cpp +++ b/src/test/overlay/TMGetObjectByHash_test.cpp @@ -468,7 +468,9 @@ class TMGetObjectByHash_test : public beast::unit_test::Suite auto reply = parseReply(peer); BEAST_EXPECT(reply.has_value()); if (reply) + { BEAST_EXPECT(reply->objects_size() == 0); + } // Positive counterpart to the oversize test: because the handler did // run, a differential charge was applied, and it is exactly the diff --git a/src/tests/libxrpl/telemetry/LedgerSpanNames.cpp b/src/tests/libxrpl/telemetry/LedgerSpanNames.cpp index 635476682b..3329af5073 100644 --- a/src/tests/libxrpl/telemetry/LedgerSpanNames.cpp +++ b/src/tests/libxrpl/telemetry/LedgerSpanNames.cpp @@ -465,8 +465,12 @@ TEST(LedgerSpanNames, phaseOutcome_covers_its_whole_input_domain) // Whenever the budget expired, the answer is `timeout` // regardless of the other two -- the precedence property, not // just the four sampled points above. + // Braced deliberately: EXPECT_EQ expands to an if/else, so an + // unbraced if around it is a dangling else, which gcc rejects. if (timedOut) + { EXPECT_EQ(outcome, std::string_view(ledger_span::val::timeout)); + } } } }