copyist
copyist copied to clipboard
-record flag example
Hi I was trying to record the output for a test and I got the following
$ go test -run TestDictWordList -record
Foo {} no recording exists with this name: TestDictWordList/Foo
PASS
I also tried with a double dash between
$ go test -run TestDictWordList -- -record
Foo {} no recording exists with this name: TestDictWordList/Foo
PASS
The only way I could get it to work was
COPYIST_RECORD=1 go test -run TestDictWordList
FTR
$ go version
go version go1.17.5 darwin/arm64
go.mod has
github.com/cockroachdb/copyist v1.4.1
I'm not sure what might be happening here. We use -record all the time without seeing this issue. I'd need a repro to dig further, if you're able to post one (e.g. a Go test file that I can run on my machine).
I suspect the problem is that the test code expects the init or TestMain functions to handle the -record
I didn't have an init or TestMain in my code, so perhaps experiment with that as a requirement?
I've just ran into this issue after using copyist for a long time with no issue.
If I add a flag.Parse() statement before I call copyist.IsRecording() then everything works.
Not yet sure why it's happening to me now all of a sudden 🤔