]> Cypherpunks repositories - gostls13.git/commit
testing: tests and benchmarks can assume flag.Parsed
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 8 May 2020 13:14:15 +0000 (14:14 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 8 May 2020 21:21:40 +0000 (21:21 +0000)
commit7cfa7d69259590319524c3715df4a39b39924bc3
tree3e7636d582d6c8706e9d4ebe8e0caa91795d12fb
parent60368c2477d2517d7d4d83412eba5420fdb81a2b
testing: tests and benchmarks can assume flag.Parsed

testing.M.Run has this bit of code:

if !flag.Parsed() {
flag.Parse()
}

It makes sense, and it's common knowledge for many Go developers that
test flags are automatically parsed by the time tests and benchmarks are
run. However, the docs didn't clarify that. The previous wording only
mentioned that flag.Parse isn't run before TestMain, which doesn't
necessarily mean that it's run afterwards.

Fixes #38952.

Change-Id: I85f7a9dce637a23c5cb9abc485d47415c1a1ca27
Reviewed-on: https://go-review.googlesource.com/c/go/+/232806
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/testing/testing.go