]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: test that 'go get pkg@version' installs pkg
authorBryan C. Mills <bcmills@google.com>
Mon, 6 Aug 2018 22:06:06 +0000 (18:06 -0400)
committerBryan C. Mills <bcmills@google.com>
Thu, 9 Aug 2018 19:59:46 +0000 (19:59 +0000)
This test passes, but it encodes several behaviors that I think are bugs.
I suggest that we check it in as-is, and we can update it as the bugs are fixed.

Change-Id: Icb073de9cb13036dbccadb4ff2cb3169ffb56236
Reviewed-on: https://go-review.googlesource.com/128137
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt [new file with mode: 0644]
src/cmd/go/testdata/script/mod_get_commit.txt
src/cmd/go/testdata/script/mod_install.txt [new file with mode: 0644]

diff --git a/src/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt b/src/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt
new file mode 100644 (file)
index 0000000..0f060dc
--- /dev/null
@@ -0,0 +1,23 @@
+research.swtch.com/vgo-tour@v1.0.0
+
+-- .mod --
+module "research.swtch.com/vgo-tour"
+-- .info --
+{"Version":"v1.0.0","Name":"84de74b35823c1e49634f2262f1a58cfc951ebae","Short":"84de74b35823","Time":"2018-02-20T00:04:00Z"}
+-- go.mod --
+module "research.swtch.com/vgo-tour"
+-- hello.go --
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+       "fmt"
+       "rsc.io/quote"
+)
+
+func main() {
+       fmt.Println(quote.Hello())
+}
index 97a10789cfe50e4297496b59c4b52d8419ebcf7a..e96f09712e61dbe8db79162962caeec999962b8f 100644 (file)
@@ -21,6 +21,15 @@ go get -d -x golang.org/x/text/language@14c0d48
 go get -x golang.org/x/text/language@14c0d48
 stderr 'compile|cp|gccgo .*language\.a$'
 
+# BUG: after the build, the package should not be stale, as 'go install' would
+# not do anything further.
+go list -f '{{.Stale}}' golang.org/x/text/language
+stdout ^true
+
+# install after get should not run the compiler again.
+go install -x golang.org/x/text/language
+! stderr 'compile|cp|gccgo .*language\.a$'
+
 # even with -d, we should see an error for unknown packages.
 ! go get -d -x golang.org/x/text/foo@14c0d48
 
diff --git a/src/cmd/go/testdata/script/mod_install.txt b/src/cmd/go/testdata/script/mod_install.txt
new file mode 100644 (file)
index 0000000..9559c46
--- /dev/null
@@ -0,0 +1,16 @@
+env GO111MODULE=on
+
+go mod init example.com/m
+
+# get of a binary should install it to $GOPATH/bin
+# BUG: vgo-tour should be installed as vgo-tour, not vgo-tour@v1.0.0.
+go get research.swtch.com/vgo-tour
+exec $GOPATH/bin/vgo-tour@v1.0.0
+stdout 'Hello, world.'
+rm $GOPATH/bin/vgo-tour@v1.0.0
+
+# install of a binary should install it to $GOPATH/bin
+# BUG: vgo-tour should be installed as vgo-tour, not vgo-tour@v1.0.0.
+go install research.swtch.com/vgo-tour
+exec $GOPATH/bin/vgo-tour@v1.0.0
+stdout 'Hello, world.'