From 6cb5a439f69db4f18dee74a91194ea9465946cb1 Mon Sep 17 00:00:00 2001 From: thepudds Date: Mon, 3 Jan 2022 15:15:08 -0500 Subject: [PATCH] gen: make "." the default constructor regex pattern --- gen/fzgen.go | 2 +- gen/genfuncs.go | 2 +- gen/genfuncsloop.go | 2 +- testscripts/external_tailscale.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gen/fzgen.go b/gen/fzgen.go index 2eb2bf3..37451d2 100644 --- a/gen/fzgen.go +++ b/gen/fzgen.go @@ -68,7 +68,7 @@ func FzgenMain() int { chainFlag := flag.Bool("chain", false, "loop over the methods of an object, which requires finding a suitable constructor in the same package and which is controllable via the -ctor flag.") parallelFlag := flag.Bool("parallel", false, "indicates an emitted chain can be run in parallel. requires -chain") outFileFlag := flag.String("o", "autofuzz_test.go", "output file name. defaults to autofuzz_test.go or autofuzzchain_test.go") - constructorPatternFlag := flag.String("ctor", "^New", "regexp to use if searching for constructors to automatically use.") + constructorPatternFlag := flag.String("ctor", ".", "regexp to use if searching for constructors to automatically use.") // Less commonly used: funcPatternFlag := flag.String("func", ".", "function regex, defaults to matching all candidate functions") diff --git a/gen/genfuncs.go b/gen/genfuncs.go index 2161dec..00e35a8 100644 --- a/gen/genfuncs.go +++ b/gen/genfuncs.go @@ -197,7 +197,7 @@ func emitIndependentWrapper(emit emitFunc, function mod.Func, constructors []mod if support == noSupport { // skip this wrapper. emit("// skipping %s because parameters include func, chan, or unsupported interface: %v\n\n", wrapperName, unsupportedParam) - return fmt.Errorf("%w: %s", errUnsupportedParams, unsupportedParam) + return fmt.Errorf("%w: %s takes %s", errUnsupportedParams, function.FuncName, unsupportedParam) } // Start emitting the wrapper function! diff --git a/gen/genfuncsloop.go b/gen/genfuncsloop.go index 60faa26..8f260cd 100644 --- a/gen/genfuncsloop.go +++ b/gen/genfuncsloop.go @@ -326,7 +326,7 @@ func emitChainTarget(emit emitFunc, function mod.Func, qualifyAll bool) error { if support == noSupport { // we can't emit this chain target. emit("// skipping %s because parameters include func, chan, or unsupported interface: %v\n\n", wrapperName, unsupportedParam) - return fmt.Errorf("%w: %s", errUnsupportedParams, unsupportedParam) + return fmt.Errorf("%w: %s takes %s", errUnsupportedParams, function.FuncName, unsupportedParam) } // Start emitting the wrapper function! diff --git a/testscripts/external_tailscale.txt b/testscripts/external_tailscale.txt index f3a8072..eed71c6 100644 --- a/testscripts/external_tailscale.txt +++ b/testscripts/external_tailscale.txt @@ -23,7 +23,7 @@ exec gotip mod tidy exec gotip get github.com/thepudds/fzgen/fuzzer exec gotip get -d ./... fzgen ./... -stdout 'fzgen: created 87 files' +stdout 'fzgen: created 91 files' exec gotip test -exec=true ./... fzgen -chain -ctor=. ./... stdout 'fzgen: created 23 files'