Skip to content

Fix -validate and add -name flags#176

Merged
alecthomas merged 3 commits intoalecthomas:masterfrom
matheusd:fix-validate
Jun 12, 2025
Merged

Fix -validate and add -name flags#176
alecthomas merged 3 commits intoalecthomas:masterfrom
matheusd:fix-validate

Conversation

@matheusd
Copy link
Copy Markdown
Contributor

-validate failures were not correctly detected when running the benchmarks with go run and could cause panics.

-name is a new flag introduced to allow generating reports and validating only a subset of the tests.

The individual commits have further explanation of each changeset.

matheusd added 3 commits June 12, 2025 09:28
This flag allows selecting a subset of benchmarks to run when generating
the report or validating benchmarks.

This is useful during development in order to verify only newly added
benchmarks as opposed to all benchmarks.
Unfortunately, benchmarks ran with testing.Benchmark() do not return an
error, panic or otherwise make their calling goroutine exit early in
order to signal failure.

This could cause validation errors to be silently ignored when running
with -validate specified.

This commit addresses this issue by using a flag to detect when the test
was prematurely finished to report it as an error, with a message for
the user to re-run the test in a way that can actually report the error.
This validation was missing from the code.
@alecthomas alecthomas merged commit 5753fe8 into alecthomas:master Jun 12, 2025
2 checks passed
@matheusd matheusd deleted the fix-validate branch June 13, 2025 09:57
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.

2 participants