Closed
Description
Package testing
says:
The entire test file is presented as the example when it contains a single example function, at least one other function, type, variable, or constant declaration, and no test or benchmark functions.
This program produces expected results in Go 1.13:
$ go1.13.10 run .
errors.As has a whole file example: false
It stopped working in Go 1.14:
$ go1.14.2 run .
errors.As has a whole file example: true
This is because CL 211357 added an early continue
when the function being considered has parameters. The intention was to skip Example functions with parameters. However, the skip happens too early, before this check:
if isTest(name, "Test") || isTest(name, "Benchmark") {
hasTests = true
continue
}
Tests and benchmarks always have 1 parameter, so hasTests
never has a chance to get set to true.
/cc @jayconrod @matloob