]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestPluginNonMain to script framework
authorMichael Matloob <matloob@golang.org>
Mon, 30 Dec 2019 23:49:27 +0000 (18:49 -0500)
committerMichael Matloob <matloob@golang.org>
Fri, 3 Jan 2020 19:02:46 +0000 (19:02 +0000)
TestPluginNonMain was broken before this change! (It provided the
wrong directory for testdep/p2: testdata/testdep/p2 instead of
testdata/src/testdep/p2).

Change-Id: Ib815f119bae1d758b500cd8ad82c016cb630d71e
Reviewed-on: https://go-review.googlesource.com/c/go/+/212938
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/build_plugin_non_main.txt [new file with mode: 0644]

index 5e332ae2acb280ec480498c93b80324235d8a6f3..2533c058fe6c217b4358e66d25bf084fa1eed3b4 100644 (file)
@@ -2281,20 +2281,6 @@ func TestCoverageDashC(t *testing.T) {
        tg.wantExecutable(tg.path("coverdep"), "go -test -c -coverprofile did not create executable")
 }
 
-func TestPluginNonMain(t *testing.T) {
-       wd, err := os.Getwd()
-       if err != nil {
-               t.Fatal(err)
-       }
-
-       pkg := filepath.Join(wd, "testdata", "testdep", "p2")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-
-       tg.runFail("build", "-buildmode=plugin", pkg)
-}
-
 func TestTestEmpty(t *testing.T) {
        if !canRace {
                t.Skip("no race detector")
diff --git a/src/cmd/go/testdata/script/build_plugin_non_main.txt b/src/cmd/go/testdata/script/build_plugin_non_main.txt
new file mode 100644 (file)
index 0000000..996d87d
--- /dev/null
@@ -0,0 +1,17 @@
+# Plugins are only supported on linux,cgo and darwin,cgo.
+[!linux] [!darwin] skip
+[!cgo] skip
+
+go build -n testdep/p2
+! go build -buildmode=plugin testdep/p2
+stderr '-buildmode=plugin requires exactly one main package'
+
+-- testdep/p1/p1.go --
+package p1
+-- testdep/p1/p1_test.go --
+package p1
+
+import _ "testdep/p2"
+-- testdep/p2/p2.go --
+package p2
+