Repository navigation
Detect gtest suites registered with GTEST_TEST in bugfix validation - #113379
Conversation
`_GTEST_MACROS` in the unit-test bugfix validator listed only `TEST`/`TEST_F`, not the `GTEST_TEST`/`GTEST_TEST_F` spellings they are `#define`d to (googletest `gtest.h:2192` -> `:2185`, `:2224` -> `:2220`). 48 registrations across 15 in-tree files under src/**/tests use the primary spelling, so `derive_test_suites` returned an empty list for those files. The validator reads that empty list as "this PR has no unit tests" rather than "the parser did not understand this file", and finalizes OK with "No gtest test suites found ... nothing to validate": a green check that validated nothing. `new_tests_check.has_new_unit_tests` imports the same predicate, so the merge gate's `has_unit` branch is not entered either. What that costs depends on what else the PR changes, and it is narrower than the validator half: `check` tests `has_ft or has_it` first (`new_tests_check.py:213`), and that predicate is decided by paths alone and never consults the gtest macros, so a PR that also adds functional or integration tests is decided by the stricter per-arch branch and is unaffected. A unit-only PR is affected: with a CI-report link in its body it passes on that fallback instead of on validation, and without one it is blocked outright. Both arms were executed against the real `check` to establish this rather than reasoned about. Over 60 days the "No gtest test suites found" verdict fired 13 times across 5 PRs, and 3 of those 5 do contain gtest cases the regex could not see, including a merged bugfix PR that shipped with 5 GTEST_TEST cases across 3 new files and its unit validation skipped. All three of those also add functional tests, so the harm there is the validator's false negative, not a gate bypass. A PR that renamed its own GTEST_TEST( to TEST( is the control: the suite became visible. Adding the two names is enough because both consumers funnel through this one tuple. No verdict, status or policy is changed and the existing entries are not reordered: alternation is first-match-wins, and the `^\s*` anchor together with the `\s*\(` suffix is what keeps the current order safe. `GTEST_TEST_F` has no in-tree users today and is listed for symmetry, as `TYPED_TEST_P` already is. Validated with a 16-case probe matrix covering every registration form, leading and odd internal whitespace, and seven negatives (macro as a substring, trailing underscore, INSTANTIATE_TEST_SUITE_P, two commented-out forms, EXPECT_TEST). Over `origin/master`, 15 files go from 0 to at least 1 derived suite with no regressions and 408 of 408 already-visible files unchanged. Exactly one file still derives 0 suites: `src/Coordination/tests/gtest_coordination_common.cpp` carries only INSTANTIATE_TEST_SUITE_P, whose first argument is a prefix and not a suite name, and its two suites are declared in the four sibling files that include its header, so `build_gtest_filter` already covers its cases. Each new assertion is pinned by a mutation arm; the gate test is deliberately not monkeypatched, since the existing unit-only test stubs the predicate and so could not catch this. Note this does not address the separate "before-binary failed to COMPILE the overlaid test" verdict of the same job, which turns on a policy question.
Internal second-model review - 2 review rounds, 2 independent gate passes, 0 open findingsBefore publishing I reviewed this change cold (without reading the implementation notes), ❌ BlockersNone.
|
| PR shape | without the fix | with the fix |
|---|---|---|
| unit-only, no CI-report link | False - blocked |
True |
| unit-only, with a CI-report link | True - the actual bypass |
True |
unit test + a 0_stateless test |
False |
False - identical |
check evaluates has_ft or has_it first (new_tests_check.py:213), and that predicate is
decided by paths alone - it never consults the gtest macros. So a PR that also adds functional
or integration tests is decided by the stricter per-arch branch and is unaffected, and the one
unit-only PR among the cited five was blocked outright rather than let through. The description
and the commit message were rewritten to state this accurately: the harm is the validator's
false negative (a green OK reading "No gtest test suites found ... nothing to validate" on a
merged bugfix PR that shipped 5 GTEST_TEST cases), and the gate consequence is narrower and
conditional. Both arms are recorded so a reader does not have to re-litigate it.
Dropped on re-derivation (mine, not the second model's): I first read the probe matrix as
missing an INSTANTIATE_TEST_SUITE_P negative. It is not missing - I had checked the
checked-in fixture rather than the runtime matrix. The finding does not survive, so no
INSTANTIATE arm was added.
💡 Noted, not blocking
- Figures were originally measured on the PR base, which is 4642 commits behind master. They
are now quoted againstorigin/masterand re-derived independently over all 437 files under
src/**/tests: 48 registrations in 15 files, 15 files go from 0 to at least 1 derived suite,
408 of 408 already-visible files unchanged, 0 regressions. The partition 408 + 15 + 14 = 437
is exhaustive, and none of the 48 occurrences sit in an already-visible file, so "15 files"
is exact. The four consumedci/files are md5-identical between that base and master, so
only the reproducibility of the numbers was ever affected, not the change. - One file legitimately still derives 0 suites and is now disclosed:
src/Coordination/tests/gtest_coordination_common.cppcarries onlyINSTANTIATE_TEST_SUITE_P,
whose first argument is a prefix and not a suite name; its two suites are declared in the four
sibling files that include its header, andbuild_gtest_filteralready emits*/Suite.*. - "seven negatives" counts the runtime probe matrix; the checked-in fixture carries six of them
(TEST_F_EXexists only in the matrix). Both counts are true of what they refer to.
Verification
- Both new tests are live: they pass as committed and both fail when
_GTEST_MACROSis
reverted to the upstream five names. The gate test deliberately does not stub the predicate -
it writes a realGTEST_TESTfile and supplies a body with no CI-report link, socheck()
can only returnTruethrough the unit branch. That is the one case the pre-existing
unit-only test could not catch, because it stubs the predicate. pytest ci/tests/: 438 passed, 4 failed - all four pre-existing and unrelated (they need a
live server), none in the two touched files.- The tuple has exactly two consumers and both funnel through the same regex, so there is no
symmetric code path left unfixed; there is no other list of gtest registration macros inci/. - Second-model review ran twice on this exact tree, once with no prior context (0 findings) and
once against the corrected description (0 findings).
Session id: cron:clickhouse-review-slot-11:20260804-185100
Pre-PR validation gate (click to expand)
Validation beyond the table: the whole Not covered here, deliberately: the separate "before-binary failed to COMPILE the overlaid test" class of this job. That one turns on a policy question and is not addressed by this PR. Session id: cron:clickhouse-impl-slot-6:20260804-182600 |
|
cc @maxknv @nickitat, could you review this? |
|
Workflow [PR], commit [edcc97e] Summary: ✅ AI ReviewSummaryThis PR fixes the unit-test bugfix validator's gtest-suite parser so direct Missing context / blind spots
Final Verdict✅ No findings. |
CI finish ledger - edcc97eCI fully finished on this head with zero failures: 174 check-runs, all Session id: cron:our-pr-ci-monitor:20260804-220000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
_GTEST_MACROSinci/jobs/unit_tests_bugfix_validation_job.pywas missingGTEST_TEST.gtest defines
TESTasGTEST_TEST(gtest.h:2192, primary at:2185; same forTEST_F/GTEST_TEST_F), and 48 registrations across 15 files undersrc/**/testsuse the primaryspelling.
derive_test_suitestherefore returned[]for such a file, and the validator read thatas "this PR has no unit tests" rather than "the parser did not understand this file": it finalizes
OKwith "No gtest test suites found ... nothing to validate". A green check that validatednothing.
new_tests_check.has_new_unit_testsdeliberately imports the same predicate, so the merge gate'sunit branch is not entered either. What that costs depends on the rest of the PR: one that also
adds functional or integration tests is decided by the stricter per-arch branch and is unaffected
(
new_tests_check.py:213tests those paths first), while a unit-only PR passes on theCI-report-link fallback if its body carries such a link.
Not hypothetical: over 60 days the "No gtest test suites found" verdict fired 13 times across 5
PRs, and 3 of those 5 do contain gtest cases the regex could not see - including #111191, a merged
bugfix PR that shipped 5
GTEST_TESTcases across 3 new files with its unit validation skipped.The fix adds
GTEST_TESTandGTEST_TEST_Fto the tuple; no verdict or policy changes and theexisting entries are not reordered. A 16-case probe matrix pins every registration form plus seven
negatives (substring, trailing underscore, instantiation, commented-out), each new assertion is
pinned by a mutation arm, and over
origin/master15 files go from 0 to >=1 derived suites with 0regressions and 408/408 already-visible files unchanged.
A
pr-bugfixPR whoseGTEST_TESTtest genuinely passes on the merge base will now be blockedwhere it previously slipped through, and such PRs now run a before-build they previously skipped
(off the critical path).
The "No gtest test suites found" verdict, CIDB 60 d, classified per PR
Each
classbelow is the verdict of the VALIDATOR, not the outcome of the merge gate: #111191,#110997 and #106961 also add
0_statelesstests, so all three were gate-decided by the per-archbranch either way.
GTEST_TESTgtest_block_*.cppgtest_aggregate_function_version_race.cppgtest_saturated_duration.cpp,gtest_settings.cppgtest_actions_dag_partial_result_type_drift.cppsrc/**/tests/Exactly one file still derives 0 suites after the fix:
src/Coordination/tests/gtest_coordination_common.cppcarries onlyINSTANTIATE_TEST_SUITE_P,whose first argument is a prefix and not a suite name; its two suites are declared in the four
sibling files that include its header, and
build_gtest_filteralready emits the*/Suite.*pattern that picks up instantiated cases. So "15 files" is not "the parser now sees everything".
Registration-macro census in
src/**/testsatorigin/master:TEST2477,TEST_F447,TEST_P212,GTEST_TEST48,TYPED_TEST22,GTEST_TEST_F0,TYPED_TEST_P0. SoGTEST_TESTwas the only macro in use that the list missed;GTEST_TEST_Fis listed for symmetry,as
TYPED_TEST_Palready is at 0 users.Version info
26.8.1.791(included in26.8and later)