Skip to content

Suggestion: enforce unique GoogleTest names #1387

@alashworth

Description

@alashworth

Description

Many tests in Stan Math have duplicate test names. You can check this with the appropriate regex | sort | uniq pipe, (e.g. rg -INo "TEST(_F|_P)?(\w*, \w*)" | sort | uniq -d)

Some tests also have the same name that are part of a test fixture, and some that are not. This is an error in GTest.

Expected:

All unit tests should have unique names.

Reason:

The GTest test runner supports filtering and running based on test name. This is also true for the CMake CTest runner. In general, when you run all the unit tests, having unique test names is necessary once you move beyond compiling individual test executables through runTests.py in order to easily see what tests are passing and failing. Also, it's a compilation error for two GTest tests to have the same name.

Eventually, I would like to support jumbo (unity) builds of the unit tests. Having unique test names is a prerequisite.

I used to maintain my own patches to the sources here, but it was an automated thing and the names were not chosen well, just the existing ones with 1 or 2 appended to the test, so I have discarded them. I would like to post this issue here just to let people know that if they make new tests, to please make sure the names are unique.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions