Commit 68fda188 authored by Daniel Martí's avatar Daniel Martí Committed by Ian Lance Taylor

all: call flag.Parse from TestMain only if used

These don't use any flags in TestMain itself, so the call is redundant
as M.Run will do it.

Change-Id: I00f2ac7f846dc2c3ad3535eb8177616b2d900149
Reviewed-on: https://go-review.googlesource.com/33275Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 7ee79365
...@@ -6,7 +6,6 @@ package main_test ...@@ -6,7 +6,6 @@ package main_test
import ( import (
"bytes" "bytes"
"flag"
"fmt" "fmt"
"go/build" "go/build"
"go/format" "go/format"
...@@ -67,8 +66,6 @@ func init() { ...@@ -67,8 +66,6 @@ func init() {
// The TestMain function creates a go command for testing purposes and // The TestMain function creates a go command for testing purposes and
// deletes it after the tests have been run. // deletes it after the tests have been run.
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
flag.Parse()
if canRun { if canRun {
args := []string{"build", "-tags", "testgo", "-o", "testgo" + exeSuffix} args := []string{"build", "-tags", "testgo", "-o", "testgo" + exeSuffix}
if race.Enabled { if race.Enabled {
......
...@@ -21,7 +21,6 @@ import ( ...@@ -21,7 +21,6 @@ import (
var tmp, exe string // populated by buildObjdump var tmp, exe string // populated by buildObjdump
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
flag.Parse()
if !testenv.HasGoBuild() { if !testenv.HasGoBuild() {
return return
} }
......
...@@ -6,7 +6,6 @@ package main_test ...@@ -6,7 +6,6 @@ package main_test
import ( import (
"bytes" "bytes"
"flag"
"fmt" "fmt"
"internal/testenv" "internal/testenv"
"os" "os"
...@@ -24,7 +23,6 @@ const ( ...@@ -24,7 +23,6 @@ const (
// We implement TestMain so remove the test binary when all is done. // We implement TestMain so remove the test binary when all is done.
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
flag.Parse()
result := m.Run() result := m.Run()
os.Remove(binary) os.Remove(binary)
os.Exit(result) os.Exit(result)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment