You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We wanted the user's command functions to return an exit code as an int
rather than calling os.Exit directly like a main function
so that we could collect coverage profiles from subprocesses.
This way, Go tests using testscript would still report the full
code coverage information even when using nested processes.
This all thankfully went away with Go 1.20, which introduced the same
feature but built right into the toolchain for both `go test`
and `go build`. As such, we were able to drop all of that code,
including the bit that we ran before os.Exit.
For more information, see:
https://go.dev/blog/integration-test-coverage
At this point, testscript users continue to use the `func() int`
signature, via e.g. `func main1() int` out of inertia,
but there's actually no good reason to keep doing that.
It causes extra boilerplate and confuses new testscript users.
Moreover, avoiding the use of os.Exit was rather tricky,
for example see the former use of flag.ContinueOnExit in our tests.
Add a new API, Main, which uses a `func()` signature just like
`func main()`, meaning that no second function declaration is needed.
Deprecate RunMain in favor of Main as well.
0 commit comments