Skip to content

Add --gtest_list_tests_brief to omit GetParam/TypeParam annotations#4971

Open
dokson wants to merge 1 commit into
google:mainfrom
dokson:feature/4937-brief-list-tests
Open

Add --gtest_list_tests_brief to omit GetParam/TypeParam annotations#4971
dokson wants to merge 1 commit into
google:mainfrom
dokson:feature/4937-brief-list-tests

Conversation

@dokson
Copy link
Copy Markdown

@dokson dokson commented May 3, 2026

Summary

  • Adds a new boolean flag --gtest_list_tests_brief (and matching GTEST_LIST_TESTS_BRIEF env var) that suppresses # GetParam() = ... and # TypeParam = ... annotations when listing tests via --gtest_list_tests.
  • Default is false, so existing behavior is preserved.
  • Motivation (from [FR]: Test names output by googletest are too long #4937): users who already provide a custom test-name generator as the 4th argument of INSTANTIATE_TEST_SUITE_P find the trailing annotation redundant; for large/binary parameter values it dominates the output and makes listings hard to read or pipe.

Why a flag and not a PrintTo workaround

The reporter of #4937 already tried supplying a PrintTo that returns an empty string. googletest still emits the literal prefix # GetParam() = before calling into the printer, so the noise can only be suppressed at the listing layer.

Test plan

  • Extended googletest/test/googletest-list-tests-unittest.py with testListTestsBriefOmitsParamAnnotations, asserting both regex match and absence of GetParam() / TypeParam = strings.
  • Full ctest suite: 45/45 tests pass on Windows / MinGW (gcc 13.2).
  • Manual verification: --help shows the new flag; flag works via both CLI and env var.

Fixes #4937

When listing parameterized tests, googletest appends
"# GetParam() = <printed value>" after each test name (and
"# TypeParam = ..." after each typed-test suite). For parameter types
with custom test-name generators (the 4th argument of
INSTANTIATE_TEST_SUITE_P), the annotation is redundant; for large
parameter values, it dominates the output.

Add a boolean flag --gtest_list_tests_brief (and matching
GTEST_LIST_TESTS_BRIEF env var) that suppresses both annotations
during --gtest_list_tests. Default is false, preserving existing
behavior. Extends googletest-list-tests-unittest.py with a regression
test.

Fixes google#4937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR]: Test names output by googletest are too long

1 participant