cmd/go: remove tests using testdata/flag_test.go

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I6573185cf14f298c51f76265f18a75e4960ce791
Reviewed-on: https://go-review.googlesource.com/c/go/+/213220
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 77917b8..0d657b2 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -2602,14 +2602,6 @@
 	}
 }
 
-func TestGoTestFlagsAfterPackage(t *testing.T) {
-	tooSlow(t)
-	tg := testgo(t)
-	defer tg.cleanup()
-	tg.run("test", "testdata/flag_test.go", "-v", "-args", "-v=7") // Two distinct -v flags.
-	tg.run("test", "-v", "testdata/flag_test.go", "-args", "-v=7") // Two distinct -v flags.
-}
-
 func TestGoTestXtestonlyWorks(t *testing.T) {
 	tg := testgo(t)
 	defer tg.cleanup()
@@ -4767,14 +4759,6 @@
 	tg.mustExist(p1)
 }
 
-func TestGoTestMinusN(t *testing.T) {
-	// Intent here is to verify that 'go test -n' works without crashing.
-	// This reuses flag_test.go, but really any test would do.
-	tg := testgo(t)
-	defer tg.cleanup()
-	tg.run("test", "testdata/flag_test.go", "-n", "-args", "-v=7")
-}
-
 func TestGoTestJSON(t *testing.T) {
 	skipIfGccgo(t, "gccgo does not have standard packages")
 	tooSlow(t)
diff --git a/src/cmd/go/testdata/flag_test.go b/src/cmd/go/testdata/flag_test.go
deleted file mode 100644
index ddf613d..0000000
--- a/src/cmd/go/testdata/flag_test.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package flag_test
-
-import (
-	"flag"
-	"log"
-	"testing"
-)
-
-var v = flag.Int("v", 0, "v flag")
-
-// Run this as go test pkg -v=7
-func TestVFlagIsSet(t *testing.T) {
-	if *v != 7 {
-		log.Fatal("v flag not set")
-	}
-}
diff --git a/src/cmd/go/testdata/script/test_flag.txt b/src/cmd/go/testdata/script/test_flag.txt
new file mode 100644
index 0000000..bbcad1c
--- /dev/null
+++ b/src/cmd/go/testdata/script/test_flag.txt
@@ -0,0 +1,22 @@
+[short] skip
+
+go test flag_test.go -v -args -v=7 # Two distinct -v flags
+go test -v flag_test.go -args -v=7 # Two distinct -v flags
+
+-- flag_test.go --
+package flag_test
+
+import (
+	"flag"
+	"log"
+	"testing"
+)
+
+var v = flag.Int("v", 0, "v flag")
+
+// Run this as go test pkg -v=7
+func TestVFlagIsSet(t *testing.T) {
+	if *v != 7 {
+		log.Fatal("v flag not set")
+	}
+}
diff --git a/src/cmd/go/testdata/script/test_minus_n.txt b/src/cmd/go/testdata/script/test_minus_n.txt
new file mode 100644
index 0000000..9900dbc
--- /dev/null
+++ b/src/cmd/go/testdata/script/test_minus_n.txt
@@ -0,0 +1,14 @@
+# The intent here is to verify that 'go test -n' works without crashing.
+# Any test will do.
+
+go test -n x_test.go
+
+-- x_test.go --
+package x_test
+
+import (
+	"testing"
+)
+
+func TestEmpty(t *testing.T) {
+}