go_test: add compatibility with fuzzing in Go 1.18+ (#2970)
The GoTestGenTest action now produces testmain.go files compatible
with Go 1.18 and lower versions. In 1.18, the function
testing.MainStart accepts a new parameter, a list of fuzz targets. We
now find those targets and pass them in for Go 1.18 and higher.
Go 1.18 is still months away, and it's possible the API may change
before then. It's likely that FuzzTarget will be renamed. That should be a
minor change though. MainStart is carved out of the Go 1 compatibility
promise and is only meant to be called by code generated by 'go test',
which we're emulating here.
This change does not add full support for fuzzing. It is possible to
start the fuzzing engine by passing --test_arg=-test.fuzz=regexp
--test_arg=-test.fuzzcachedir=dir. However, if a crash is found,
there's nowhere for the fuzzing engine to write it.
For #2284
4 files changed