From 6140829edf611243a41393823217f604ca6d33a2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 18 Jul 2018 09:08:45 -0400 Subject: [PATCH] cmd/go: convert still more module tests to scripts Change-Id: I249bb848c9911948dbd84cd88ad043a61ed6ea6b Reviewed-on: https://go-review.googlesource.com/124699 Reviewed-by: Bryan C. Mills --- src/cmd/go/mod_test.go | 265 ------------------ src/cmd/go/script_test.go | 15 +- src/cmd/go/testdata/rsc.io_quote_0d003b9.txt | 166 ----------- src/cmd/go/testdata/rsc.io_quote_5d9f230.txt | 151 ---------- src/cmd/go/testdata/rsc.io_quote_a91498b.txt | 148 ---------- src/cmd/go/testdata/rsc.io_quote_b44a0b1.txt | 169 ----------- src/cmd/go/testdata/rsc.io_quote_fe488b8.txt | 151 ---------- src/cmd/go/testdata/script/mod_file_proxy.txt | 16 +- src/cmd/go/testdata/script/mod_get_commit.txt | 44 +++ .../go/testdata/script/mod_get_downgrade.txt | 11 + .../go/testdata/script/mod_get_indirect.txt | 42 +++ .../go/testdata/script/mod_get_upgrade.txt | 41 +++ .../go/testdata/script/mod_getmode_vendor.txt | 23 ++ src/cmd/go/testdata/script/mod_import.txt | 18 ++ .../go/testdata/script/mod_list_upgrade.txt | 8 + src/cmd/go/testdata/script/mod_multirepo.txt | 40 +++ src/cmd/go/testdata/script/mod_query.txt | 24 ++ .../go/testdata/script/mod_upgrade_patch.txt | 29 ++ 18 files changed, 301 insertions(+), 1060 deletions(-) delete mode 100644 src/cmd/go/testdata/rsc.io_quote_0d003b9.txt delete mode 100644 src/cmd/go/testdata/rsc.io_quote_5d9f230.txt delete mode 100644 src/cmd/go/testdata/rsc.io_quote_a91498b.txt delete mode 100644 src/cmd/go/testdata/rsc.io_quote_b44a0b1.txt delete mode 100644 src/cmd/go/testdata/rsc.io_quote_fe488b8.txt create mode 100644 src/cmd/go/testdata/script/mod_get_commit.txt create mode 100644 src/cmd/go/testdata/script/mod_get_downgrade.txt create mode 100644 src/cmd/go/testdata/script/mod_get_indirect.txt create mode 100644 src/cmd/go/testdata/script/mod_get_upgrade.txt create mode 100644 src/cmd/go/testdata/script/mod_getmode_vendor.txt create mode 100644 src/cmd/go/testdata/script/mod_import.txt create mode 100644 src/cmd/go/testdata/script/mod_list_upgrade.txt create mode 100644 src/cmd/go/testdata/script/mod_multirepo.txt create mode 100644 src/cmd/go/testdata/script/mod_query.txt create mode 100644 src/cmd/go/testdata/script/mod_upgrade_patch.txt diff --git a/src/cmd/go/mod_test.go b/src/cmd/go/mod_test.go index 8ba2ed31e2..cfd5de5221 100644 --- a/src/cmd/go/mod_test.go +++ b/src/cmd/go/mod_test.go @@ -10,9 +10,7 @@ import ( "io/ioutil" "os" "path/filepath" - "regexp" "sort" - "strings" "testing" "cmd/go/internal/cfg" @@ -414,226 +412,6 @@ require x.3 v1.99.0 `) } -func TestModGetVersions(t *testing.T) { - tg := testGoModules(t) - defer tg.cleanup() - - tg.setenv(homeEnvName(), tg.path("home")) - tg.must(os.MkdirAll(tg.path("x"), 0777)) - tg.cd(tg.path("x")) - tg.must(ioutil.WriteFile(tg.path("x/x.go"), []byte(`package x`), 0666)) - - tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(` - module x - require rsc.io/quote v1.1.0 - `), 0666)) - tg.run("get", "rsc.io/quote@v2.0.0") - tg.run("list", "-m", "all") - tg.grepStdout("rsc.io/quote.*v0.0.0-20180709153244-fd906ed3b100", "did downgrade to v0.0.0-*") - - tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(` - module x - require rsc.io/quote v1.2.0 - `), 0666)) - tg.run("get", "rsc.io/quote@v1.1.0") - tg.run("list", "-m", "-u", "all") - tg.grepStdout(`rsc.io/quote v1.1.0`, "did downgrade to v1.1.0") - tg.grepStdout(`rsc.io/quote v1.1.0 \[v1`, "did show upgrade to v1.2.0 or later") - - tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(` - module x - require rsc.io/quote v1.1.0 - `), 0666)) - tg.run("get", "rsc.io/quote@v1.2.0") - tg.run("list", "-m", "all") - tg.grepStdout("rsc.io/quote.*v1.2.0", "did upgrade to v1.2.0") - - // @14c0d48ead0c should resolve, - // and also there should be no build error about not having Go files in the root. - tg.run("get", "golang.org/x/text@14c0d48ead0c") - - // @14c0d48ead0c should resolve. - // Now there should be no build at all. - tg.run("get", "-m", "golang.org/x/text@14c0d48ead0c") - - // language@7f39a6fea4fe9364 should not resolve with -m, - // because .../language is not a module path. - tg.runFail("get", "-m", "golang.org/x/text/language@14c0d48ead0c") - - // language@7f39a6fea4fe9364 should resolve without -m. - // Because of -d, there should be no build at all. - tg.run("get", "-d", "-x", "golang.org/x/text/language@14c0d48ead0c") - tg.grepStderrNot(`compile|cp .*language\.a$`, "should not see compile steps") - - // Dropping -d, we should see a build now. - tg.run("get", "-x", "golang.org/x/text/language@14c0d48ead0c") - tg.grepStderr(`compile|cp .*language\.a$`, "should see compile steps") - - // Even with -d, we should see an error for unknown packages. - tg.runFail("get", "-x", "golang.org/x/text/foo@14c0d48ead0c") -} - -func TestModGetUpgrade(t *testing.T) { - tg := testGoModules(t) - defer tg.cleanup() - - tg.setenv(homeEnvName(), tg.path("home")) - tg.must(os.MkdirAll(tg.path("x"), 0777)) - tg.cd(tg.path("x")) - tg.must(ioutil.WriteFile(tg.path("x/x.go"), []byte(`package x; import _ "rsc.io/quote"`), 0666)) - - tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(` - module x - require rsc.io/quote v1.5.1 - `), 0666)) - - tg.run("get", "-x", "-u") - tg.run("list", "-m", "-f={{.Path}} {{.Version}}{{if .Indirect}} // indirect{{end}}", "all") - tg.grepStdout(`quote v1.5.2$`, "should have upgraded only to v1.5.2") - tg.grepStdout(`x/text [v0-9a-f.\-]+ // indirect`, "should list golang.org/x/text as indirect") - - var gomod string - readGoMod := func() { - data, err := ioutil.ReadFile(tg.path("x/go.mod")) - if err != nil { - t.Fatal(err) - } - gomod = string(data) - } - readGoMod() - if !strings.Contains(gomod, "rsc.io/quote v1.5.2\n") { - t.Fatalf("expected rsc.io/quote direct requirement:\n%s", gomod) - } - if !regexp.MustCompile(`(?m)golang.org/x/text.* // indirect`).MatchString(gomod) { - t.Fatalf("expected golang.org/x/text indirect requirement:\n%s", gomod) - } - - tg.must(ioutil.WriteFile(tg.path("x/x.go"), []byte(`package x; import _ "golang.org/x/text"`), 0666)) - tg.run("list") // rescans directory - readGoMod() - if !strings.Contains(gomod, "rsc.io/quote v1.5.2\n") { - t.Fatalf("expected rsc.io/quote direct requirement:\n%s", gomod) - } - if !regexp.MustCompile(`(?m)golang.org/x/text[^/]+\n`).MatchString(gomod) { - t.Fatalf("expected golang.org/x/text DIRECT requirement:\n%s", gomod) - } - - tg.must(ioutil.WriteFile(tg.path("x/x.go"), []byte(`package x; import _ "rsc.io/quote"`), 0666)) - tg.run("mod", "-sync") // rescans everything, can put // indirect marks back - readGoMod() - if !strings.Contains(gomod, "rsc.io/quote v1.5.2\n") { - t.Fatalf("expected rsc.io/quote direct requirement:\n%s", gomod) - } - if !regexp.MustCompile(`(?m)golang.org/x/text.* // indirect\n`).MatchString(gomod) { - t.Fatalf("expected golang.org/x/text indirect requirement:\n%s", gomod) - } - - tg.run("get", "rsc.io/quote@v0.0.0-20180214005840-23179ee8a569") // should record as (time-corrected) pseudo-version - readGoMod() - if !strings.Contains(gomod, "rsc.io/quote v0.0.0-20180214005840-23179ee8a569\n") { - t.Fatalf("expected rsc.io/quote v0.0.0-20180214005840-23179ee8a569 (not v1.5.1)\n%s", gomod) - } - - tg.run("get", "rsc.io/quote@23179ee") // should record as v1.5.1 - readGoMod() - if !strings.Contains(gomod, "rsc.io/quote v1.5.1\n") { - t.Fatalf("expected rsc.io/quote v1.5.1 (not 23179ee)\n%s", gomod) - } - - tg.run("mod", "-require", "rsc.io/quote@23179ee") // should record as 23179ee - readGoMod() - if !strings.Contains(gomod, "rsc.io/quote 23179ee\n") { - t.Fatalf("expected rsc.io/quote 23179ee\n%s", gomod) - } - - tg.run("mod", "-fix") // fixup in any future go command should find v1.5.1 again - readGoMod() - if !strings.Contains(gomod, "rsc.io/quote v1.5.1\n") { - t.Fatalf("expected rsc.io/quote v1.5.1\n%s", gomod) - } - - tg.run("get", "-m", "rsc.io/quote@dd9747d") - tg.run("list", "-m", "all") - tg.grepStdout(`quote v0.0.0-20180628003336-dd9747d19b04$`, "should have moved to pseudo-commit") - - tg.run("get", "-m", "-u") - tg.run("list", "-m", "all") - tg.grepStdout(`quote v0.0.0-20180628003336-dd9747d19b04$`, "should have stayed on pseudo-commit") - - tg.run("get", "-m", "rsc.io/quote@e7a685a342") - tg.run("list", "-m", "all") - tg.grepStdout(`quote v0.0.0-20180214005133-e7a685a342c0$`, "should have moved to new pseudo-commit") - - tg.run("get", "-m", "-u") - tg.run("list", "-m", "all") - tg.grepStdout(`quote v1.5.2$`, "should have moved off pseudo-commit") - - tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(` - module x - `), 0666)) - tg.run("list") - tg.run("list", "-m", "all") - tg.grepStdout(`quote v1.5.2$`, "should have added quote v1.5.2") - tg.grepStdoutNot(`v1.5.3-pre1`, "should not mention v1.5.3-pre1") - - tg.run("list", "-m", "-versions", "rsc.io/quote") - want := "rsc.io/quote v1.0.0 v1.1.0 v1.2.0 v1.2.1 v1.3.0 v1.4.0 v1.5.0 v1.5.1 v1.5.2 v1.5.3-pre1\n" - if tg.getStdout() != want { - t.Errorf("go list versions:\nhave:\n%s\nwant:\n%s", tg.getStdout(), want) - } - - tg.run("list", "-m", "rsc.io/quote@>v1.5.2") - tg.grepStdout(`v1.5.3-pre1`, "expected to find v1.5.3-pre1") - tg.run("list", "-m", "rsc.io/quote@v1.5.3") - tg.grepStderr(`go list -m rsc.io/quote: no matching versions for query ">v1.5.3"`, "expected no matching version") - - tg.run("list", "-m", "-e", "-f={{.Error.Err}}", "rsc.io/quote@>v1.5.3") - tg.grepStdout(`no matching versions for query ">v1.5.3"`, "expected no matching version") - - tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(` - module x - require rsc.io/quote v1.4.0 - `), 0666)) - - tg.run("list", "-m", "all") - tg.grepStdout(`rsc.io/sampler v1.0.0`, "expected sampler v1.0.0") - - tg.run("get", "-m", "-u=patch", "rsc.io/quote") - tg.run("list", "-m", "all") - tg.grepStdout(`rsc.io/quote v1.5.2`, "expected quote v1.5.2") // rsc.io/quote gets implicit @latest (not -u=patch) - tg.grepStdout(`rsc.io/sampler v1.3.1`, "expected sampler v1.3.1") // even though v1.5.2 requires v1.3.0 - tg.grepStdout(`golang.org/x/text v0.0.0-`, "expected x/text pseudo-version") // can't jump from v0.0.0- to v0.3.0 - - tg.run("get", "-m", "-u=patch", "rsc.io/quote@v1.2.0") - tg.run("list", "-m", "all") - tg.grepStdout(`rsc.io/quote v1.2.0`, "expected quote v1.2.0") // not v1.2.1: -u=patch applies to deps of args, not args - tg.grepStdout(`rsc.io/sampler v1.3.1`, "expected sampler line to stay") // even though v1.2.0 does not require sampler? - - tg.run("get", "-m", "-u=patch") - tg.run("list", "-m", "all") - tg.grepStdout(`rsc.io/quote v1.2.1`, "expected quote v1.2.1") // -u=patch with no args applies to deps of main module - tg.grepStdout(`rsc.io/sampler v1.3.1`, "expected sampler line to stay") - tg.grepStdout(`golang.org/x/text v0.0.0-`, "expected x/text pseudo-version") // even though x/text v0.3.0 is tagged - - tg.run("get", "-m", "rsc.io/quote@v1.5.1") - tg.run("mod", "-vendor") - tg.setenv("GOPATH", tg.path("empty")) - tg.setenv("GOPROXY", "file:///nonexist") - - tg.run("list", "-getmode=vendor", "all") - tg.run("list", "-getmode=vendor", "-m", "-f={{.Path}} {{.Version}} {{.Dir}}", "all") - tg.grepStdout(`rsc.io/quote v1.5.1 .*vendor[\\/]rsc.io[\\/]quote`, "expected vendored rsc.io/quote") - tg.grepStdout(`golang.org/x/text v0.0.0.* .*vendor[\\/]golang.org[\\/]x[\\/]text`, "expected vendored golang.org/x/text") - - tg.runFail("list", "-getmode=vendor", "-m", "rsc.io/quote@latest") - tg.grepStderr(`module lookup disabled by -getmode=vendor`, "expected disabled") - tg.runFail("get", "-getmode=vendor", "-u") - tg.grepStderr(`go get: disabled by -getmode=vendor`, "expected disabled") -} - func TestModSync(t *testing.T) { tg := testGoModules(t) defer tg.cleanup() @@ -793,46 +571,3 @@ func TestModVendor(t *testing.T) { tg.run("test", "-getmode=vendor", "./...") } } - -func TestModMultiVersion(t *testing.T) { - tg := testGoModules(t) - defer tg.cleanup() - - checkModules := func(dirs ...string) { - t.Helper() - tg.run("list", "-deps", "-f", "{{.ImportPath}}: {{.Dir}}") - for _, line := range strings.Split(tg.getStdout(), "\n") { - line = strings.Replace(line, `\`, `/`, -1) // windows! - if strings.HasPrefix(line, "rsc.io/quote: ") { - if strings.Contains(line, "/src/mod/") { - t.Fatalf("rsc.io/quote should not be from module cache: %v", line) - } - } else if strings.Contains(line, "rsc.io/quote") { - if !strings.Contains(line, "/src/mod/") { - t.Fatalf("rsc.io/quote/* should be from module cache: %v", line) - } - } - } - } - - tg.extract("testdata/mod/rsc.io_quote_v1.5.2.txt") - checkModules() - - // These are git checkouts from rsc.io/quote not downlaoded modules. - // As such they contain extra files like spurious pieces of other modules. - tg.extract("testdata/rsc.io_quote_0d003b9.txt") // wraps v2 - checkModules() - - tg.extract("testdata/rsc.io_quote_b44a0b1.txt") // adds go.mod - checkModules() - - tg.extract("testdata/rsc.io_quote_fe488b8.txt") // adds broken v3 subdirectory - tg.run("list", "./...") // should ignore v3 because v3/go.mod exists - checkModules() - - tg.extract("testdata/rsc.io_quote_a91498b.txt") // wraps v3 - checkModules() // looks up v3 from internet, not v3 subdirectory - - tg.extract("testdata/rsc.io_quote_5d9f230.txt") // adds go.mod - checkModules() // knows which v3 to use (still needs download from internet, cached from last step) -} diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index 8d05f69dd9..327dc7e8d4 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -569,7 +569,9 @@ func scriptMatch(ts *testScript, neg bool, args []string, text, name string) { re, err := regexp.Compile(`(?m)` + pattern) ts.check(err) - if name == "grep" { + isGrep := name == "grep" + if isGrep { + name = args[1] // for error messages data, err := ioutil.ReadFile(ts.mkabs(args[1])) ts.check(err) text = string(data) @@ -577,15 +579,24 @@ func scriptMatch(ts *testScript, neg bool, args []string, text, name string) { if neg { if re.MatchString(text) { - ts.fatalf("unexpected match for %#q found in %s: %s %q", pattern, name, text, re.FindString(text)) + if isGrep { + fmt.Fprintf(&ts.log, "[%s]\n%s\n", name, text) + } + ts.fatalf("unexpected match for %#q found in %s: %s", pattern, name, re.FindString(text)) } } else { if !re.MatchString(text) { + if isGrep { + fmt.Fprintf(&ts.log, "[%s]\n%s\n", name, text) + } ts.fatalf("no match for %#q found in %s", pattern, name) } if n > 0 { count := len(re.FindAllString(text, -1)) if count != n { + if isGrep { + fmt.Fprintf(&ts.log, "[%s]\n%s\n", name, text) + } ts.fatalf("have %d matches for %#q, want %d", count, pattern, n) } } diff --git a/src/cmd/go/testdata/rsc.io_quote_0d003b9.txt b/src/cmd/go/testdata/rsc.io_quote_0d003b9.txt deleted file mode 100644 index 9b2817f5dd..0000000000 --- a/src/cmd/go/testdata/rsc.io_quote_0d003b9.txt +++ /dev/null @@ -1,166 +0,0 @@ -generated by: go run savedir.go . - --- LICENSE -- -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- README.md -- -This package collects pithy sayings. - -It's part of a demonstration of -[package versioning in Go](https://research.swtch.com/vgo1). --- buggy/buggy_test.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 buggy - -import "testing" - -func Test(t *testing.T) { - t.Fatal("buggy!") -} --- go.mod -- -module rsc.io/quote - -require rsc.io/sampler v1.3.0 --- quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/quote/v2" - -// Hello returns a greeting. -func Hello() string { - return quote.HelloV2() -} - -// Glass returns a useful phrase for world travelers. -func Glass() string { - // See http://www.oocities.org/nodotus/hbglass.html. - return quote.GlassV2() -} - -// Go returns a Go proverb. -func Go() string { - return quote.GoV2() -} - -// Opt returns an optimization truth. -func Opt() string { - // Wisdom from ken. - return quote.OptV2() -} --- quote_test.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 quote - -import ( - "os" - "testing" -) - -func init() { - os.Setenv("LC_ALL", "en") -} - -func TestHello(t *testing.T) { - hello := "Hello, world." - if out := Hello(); out != hello { - t.Errorf("Hello() = %q, want %q", out, hello) - } -} - -func TestGlass(t *testing.T) { - glass := "I can eat glass and it doesn't hurt me." - if out := Glass(); out != glass { - t.Errorf("Glass() = %q, want %q", out, glass) - } -} - -func TestGo(t *testing.T) { - go1 := "Don't communicate by sharing memory, share memory by communicating." - if out := Go(); out != go1 { - t.Errorf("Go() = %q, want %q", out, go1) - } -} - -func TestOpt(t *testing.T) { - opt := "If a program is too slow, it must have a loop." - if out := Opt(); out != opt { - t.Errorf("Opt() = %q, want %q", out, opt) - } -} --- v3/go.mod -- -module rsc.io/quote/v3 - -require rsc.io/sampler v1.3.0 - --- v3/go.sum -- -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -rsc.io/sampler v1.99.99 h1:7i08f/p5TBU5joCPW3GjWG1ZFCmr28ybGqlXtelhEK8= -rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= --- v3/quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/sampler" - -// Hello returns a greeting. -func HelloV3() string { - return sampler.Hello() -} - -// Glass returns a useful phrase for world travelers. -func GlassV3() string { - // See http://www.oocities.org/nodotus/hbglass.html. - return "I can eat glass and it doesn't hurt me." -} - -// Go returns a Go proverb. -func GoV3() string { - return "Don't communicate by sharing memory, share memory by communicating." -} - -// Opt returns an optimization truth. -func OptV3() string { - // Wisdom from ken. - return "If a program is too slow, it must have a loop." -} diff --git a/src/cmd/go/testdata/rsc.io_quote_5d9f230.txt b/src/cmd/go/testdata/rsc.io_quote_5d9f230.txt deleted file mode 100644 index 8f8bdc4b3c..0000000000 --- a/src/cmd/go/testdata/rsc.io_quote_5d9f230.txt +++ /dev/null @@ -1,151 +0,0 @@ -generated by: go run savedir.go . - --- LICENSE -- -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- README.md -- -This package collects pithy sayings. - -It's part of a demonstration of -[package versioning in Go](https://research.swtch.com/vgo1). --- buggy/buggy_test.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 buggy - -import "testing" - -func Test(t *testing.T) { - t.Fatal("buggy!") -} --- go.mod -- -module rsc.io/quote - -require ( - rsc.io/quote/v3 v3.0.0 - rsc.io/sampler v1.3.0 -) --- quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/quote/v3" - -// Hello returns a greeting. -func Hello() string { - return quote.HelloV3() -} - -// Glass returns a useful phrase for world travelers. -func Glass() string { - // See http://www.oocities.org/nodotus/hbglass.html. - return quote.GlassV3() -} - -// Go returns a Go proverb. -func Go() string { - return quote.GoV3() -} - -// Opt returns an optimization truth. -func Opt() string { - // Wisdom from ken. - return quote.OptV3() -} --- quote_test.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 quote - -import ( - "os" - "testing" -) - -func init() { - os.Setenv("LC_ALL", "en") -} - -func TestHello(t *testing.T) { - hello := "Hello, world." - if out := Hello(); out != hello { - t.Errorf("Hello() = %q, want %q", out, hello) - } -} - -func TestGlass(t *testing.T) { - glass := "I can eat glass and it doesn't hurt me." - if out := Glass(); out != glass { - t.Errorf("Glass() = %q, want %q", out, glass) - } -} - -func TestGo(t *testing.T) { - go1 := "Don't communicate by sharing memory, share memory by communicating." - if out := Go(); out != go1 { - t.Errorf("Go() = %q, want %q", out, go1) - } -} - -func TestOpt(t *testing.T) { - opt := "If a program is too slow, it must have a loop." - if out := Opt(); out != opt { - t.Errorf("Opt() = %q, want %q", out, opt) - } -} --- v3/go.mod -- -module rsc.io/quote/v3 - -require rsc.io/sampler v1.3.0 - --- v3/go.sum -- -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -rsc.io/sampler v1.99.99 h1:7i08f/p5TBU5joCPW3GjWG1ZFCmr28ybGqlXtelhEK8= -rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= --- v3/quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/sampler" - -// Hello returns a greeting. -func HelloV3() string { - return sampler.Hello() diff --git a/src/cmd/go/testdata/rsc.io_quote_a91498b.txt b/src/cmd/go/testdata/rsc.io_quote_a91498b.txt deleted file mode 100644 index 8567243c01..0000000000 --- a/src/cmd/go/testdata/rsc.io_quote_a91498b.txt +++ /dev/null @@ -1,148 +0,0 @@ -generated by: go run savedir.go . - --- LICENSE -- -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- README.md -- -This package collects pithy sayings. - -It's part of a demonstration of -[package versioning in Go](https://research.swtch.com/vgo1). --- buggy/buggy_test.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 buggy - -import "testing" - -func Test(t *testing.T) { - t.Fatal("buggy!") -} --- go.mod -- -module rsc.io/quote - -require rsc.io/sampler v1.3.0 --- quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/quote/v3" - -// Hello returns a greeting. -func Hello() string { - return quote.HelloV3() -} - -// Glass returns a useful phrase for world travelers. -func Glass() string { - // See http://www.oocities.org/nodotus/hbglass.html. - return quote.GlassV3() -} - -// Go returns a Go proverb. -func Go() string { - return quote.GoV3() -} - -// Opt returns an optimization truth. -func Opt() string { - // Wisdom from ken. - return quote.OptV3() -} --- quote_test.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 quote - -import ( - "os" - "testing" -) - -func init() { - os.Setenv("LC_ALL", "en") -} - -func TestHello(t *testing.T) { - hello := "Hello, world." - if out := Hello(); out != hello { - t.Errorf("Hello() = %q, want %q", out, hello) - } -} - -func TestGlass(t *testing.T) { - glass := "I can eat glass and it doesn't hurt me." - if out := Glass(); out != glass { - t.Errorf("Glass() = %q, want %q", out, glass) - } -} - -func TestGo(t *testing.T) { - go1 := "Don't communicate by sharing memory, share memory by communicating." - if out := Go(); out != go1 { - t.Errorf("Go() = %q, want %q", out, go1) - } -} - -func TestOpt(t *testing.T) { - opt := "If a program is too slow, it must have a loop." - if out := Opt(); out != opt { - t.Errorf("Opt() = %q, want %q", out, opt) - } -} --- v3/go.mod -- -module rsc.io/quote/v3 - -require rsc.io/sampler v1.3.0 - --- v3/go.sum -- -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -rsc.io/sampler v1.99.99 h1:7i08f/p5TBU5joCPW3GjWG1ZFCmr28ybGqlXtelhEK8= -rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= --- v3/quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/sampler" - -// Hello returns a greeting. -func HelloV3() string { - return sampler.Hello() diff --git a/src/cmd/go/testdata/rsc.io_quote_b44a0b1.txt b/src/cmd/go/testdata/rsc.io_quote_b44a0b1.txt deleted file mode 100644 index 37f298f839..0000000000 --- a/src/cmd/go/testdata/rsc.io_quote_b44a0b1.txt +++ /dev/null @@ -1,169 +0,0 @@ -generated by: go run savedir.go . - --- LICENSE -- -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- README.md -- -This package collects pithy sayings. - -It's part of a demonstration of -[package versioning in Go](https://research.swtch.com/vgo1). --- buggy/buggy_test.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 buggy - -import "testing" - -func Test(t *testing.T) { - t.Fatal("buggy!") -} --- go.mod -- -module rsc.io/quote - -require ( - rsc.io/quote/v2 v2.0.1 - rsc.io/sampler v1.3.0 -) --- quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/quote/v2" - -// Hello returns a greeting. -func Hello() string { - return quote.HelloV2() -} - -// Glass returns a useful phrase for world travelers. -func Glass() string { - // See http://www.oocities.org/nodotus/hbglass.html. - return quote.GlassV2() -} - -// Go returns a Go proverb. -func Go() string { - return quote.GoV2() -} - -// Opt returns an optimization truth. -func Opt() string { - // Wisdom from ken. - return quote.OptV2() -} --- quote_test.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 quote - -import ( - "os" - "testing" -) - -func init() { - os.Setenv("LC_ALL", "en") -} - -func TestHello(t *testing.T) { - hello := "Hello, world." - if out := Hello(); out != hello { - t.Errorf("Hello() = %q, want %q", out, hello) - } -} - -func TestGlass(t *testing.T) { - glass := "I can eat glass and it doesn't hurt me." - if out := Glass(); out != glass { - t.Errorf("Glass() = %q, want %q", out, glass) - } -} - -func TestGo(t *testing.T) { - go1 := "Don't communicate by sharing memory, share memory by communicating." - if out := Go(); out != go1 { - t.Errorf("Go() = %q, want %q", out, go1) - } -} - -func TestOpt(t *testing.T) { - opt := "If a program is too slow, it must have a loop." - if out := Opt(); out != opt { - t.Errorf("Opt() = %q, want %q", out, opt) - } -} --- v3/go.mod -- -module rsc.io/quote/v3 - -require rsc.io/sampler v1.3.0 - --- v3/go.sum -- -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -rsc.io/sampler v1.99.99 h1:7i08f/p5TBU5joCPW3GjWG1ZFCmr28ybGqlXtelhEK8= -rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= --- v3/quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/sampler" - -// Hello returns a greeting. -func HelloV3() string { - return sampler.Hello() -} - -// Glass returns a useful phrase for world travelers. -func GlassV3() string { - // See http://www.oocities.org/nodotus/hbglass.html. - return "I can eat glass and it doesn't hurt me." -} - -// Go returns a Go proverb. -func GoV3() string { - return "Don't communicate by sharing memory, share memory by communicating." -} - -// Opt returns an optimization truth. -func OptV3() string { - // Wisdom from ken. - return "If a program is too slow, it must have a loop." -} diff --git a/src/cmd/go/testdata/rsc.io_quote_fe488b8.txt b/src/cmd/go/testdata/rsc.io_quote_fe488b8.txt deleted file mode 100644 index fb80e5121b..0000000000 --- a/src/cmd/go/testdata/rsc.io_quote_fe488b8.txt +++ /dev/null @@ -1,151 +0,0 @@ -generated by: go run savedir.go . - --- LICENSE -- -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- README.md -- -This package collects pithy sayings. - -It's part of a demonstration of -[package versioning in Go](https://research.swtch.com/vgo1). --- buggy/buggy_test.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 buggy - -import "testing" - -func Test(t *testing.T) { - t.Fatal("buggy!") -} --- go.mod -- -module rsc.io/quote - -require ( - rsc.io/quote/v2 v2.0.1 - rsc.io/sampler v1.3.0 -) --- quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/quote/v2" - -// Hello returns a greeting. -func Hello() string { - return quote.HelloV2() -} - -// Glass returns a useful phrase for world travelers. -func Glass() string { - // See http://www.oocities.org/nodotus/hbglass.html. - return quote.GlassV2() -} - -// Go returns a Go proverb. -func Go() string { - return quote.GoV2() -} - -// Opt returns an optimization truth. -func Opt() string { - // Wisdom from ken. - return quote.OptV2() -} --- quote_test.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 quote - -import ( - "os" - "testing" -) - -func init() { - os.Setenv("LC_ALL", "en") -} - -func TestHello(t *testing.T) { - hello := "Hello, world." - if out := Hello(); out != hello { - t.Errorf("Hello() = %q, want %q", out, hello) - } -} - -func TestGlass(t *testing.T) { - glass := "I can eat glass and it doesn't hurt me." - if out := Glass(); out != glass { - t.Errorf("Glass() = %q, want %q", out, glass) - } -} - -func TestGo(t *testing.T) { - go1 := "Don't communicate by sharing memory, share memory by communicating." - if out := Go(); out != go1 { - t.Errorf("Go() = %q, want %q", out, go1) - } -} - -func TestOpt(t *testing.T) { - opt := "If a program is too slow, it must have a loop." - if out := Opt(); out != opt { - t.Errorf("Opt() = %q, want %q", out, opt) - } -} --- v3/go.mod -- -module rsc.io/quote/v3 - -require rsc.io/sampler v1.3.0 - --- v3/go.sum -- -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -rsc.io/sampler v1.99.99 h1:7i08f/p5TBU5joCPW3GjWG1ZFCmr28ybGqlXtelhEK8= -rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= --- v3/quote.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 quote collects pithy sayings. -package quote // import "rsc.io/quote" - -import "rsc.io/sampler" - -// Hello returns a greeting. -func HelloV3() string { - return sampler.Hello() diff --git a/src/cmd/go/testdata/script/mod_file_proxy.txt b/src/cmd/go/testdata/script/mod_file_proxy.txt index 4e93ff1a9e..c82b9cf031 100644 --- a/src/cmd/go/testdata/script/mod_file_proxy.txt +++ b/src/cmd/go/testdata/script/mod_file_proxy.txt @@ -2,21 +2,21 @@ env GO111MODULE=on env GOPATH=$WORK/gopath1 cd $WORK/x -! go list -getmode=local all -go list all -go list -getmode=local all +! go list -getmode=local +go list +go list -getmode=local env GOPROXY=file:///nonexist -go list -getmode=local all +go list -getmode=local grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list # Use download cache as file:/// proxy. env GOPATH=$WORK/gopath2 env GOPROXY=file:///nonexist -! go list -getmode=local all -! go list all +! go list -getmode=local +! go list env GOPROXY=file://$WORK/gopath1/src/mod/cache/download -! go list -getmode=local all -go list all +! go list -getmode=local +go list grep v1.5.1 $GOPATH/src/mod/cache/download/rsc.io/quote/@v/list -- $WORK/x/go.mod -- diff --git a/src/cmd/go/testdata/script/mod_get_commit.txt b/src/cmd/go/testdata/script/mod_get_commit.txt new file mode 100644 index 0000000000..465767135c --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_commit.txt @@ -0,0 +1,44 @@ +env GO111MODULE=on + +# @commit should resolve + +# go get should skip build with no Go files in root +go get golang.org/x/text@14c0d48 + +# ... and go get should skip build with -m +go get -m golang.org/x/text@14c0d48 + +# golang.org/x/text/language@commit should not resolve with -m, +# because that's not a module path. +! go get -m golang.org/x/text/language@14c0d48 + +# ... but it should work without -m. +# because of -d, the compiler should not run +go get -d -x golang.org/x/text/language@14c0d48 +! stderr 'compile|cp|gccgo .*language\.a$' + +# dropping -d, we should see a build. +go get -x golang.org/x/text/language@14c0d48 +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 + +# get pseudo-version should record that version +go get rsc.io/quote@v0.0.0-20180214005840-23179ee8a569 +grep 'rsc.io/quote v0.0.0-20180214005840-23179ee8a569' go.mod + +# but as commit should record as v1.5.1 +go get rsc.io/quote@23179ee8 +grep 'rsc.io/quote v1.5.1' go.mod + +# go mod -require does not interpret commits +go mod -require rsc.io/quote@23179ee +grep 'rsc.io/quote 23179ee' go.mod + +# but go mod -fix fixes them +go mod -fix +grep 'rsc.io/quote v1.5.1' go.mod + +-- go.mod -- +module x diff --git a/src/cmd/go/testdata/script/mod_get_downgrade.txt b/src/cmd/go/testdata/script/mod_get_downgrade.txt new file mode 100644 index 0000000000..e953ac5331 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_downgrade.txt @@ -0,0 +1,11 @@ +env GO111MODULE=on + +go get rsc.io/quote@v2.0.0 +go list -m all +stdout 'rsc.io/quote v0.0.0-' + +-- go.mod -- +module x +require rsc.io/quote v1.5.1 +-- x.go -- +package x diff --git a/src/cmd/go/testdata/script/mod_get_indirect.txt b/src/cmd/go/testdata/script/mod_get_indirect.txt new file mode 100644 index 0000000000..f4ee5bf590 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_indirect.txt @@ -0,0 +1,42 @@ +env GO111MODULE=on + +# get -u should find quote v1.5.2 +go get -u +go list -m all +stdout 'quote v1.5.2$' +grep 'rsc.io/quote v1.5.2$' go.mod + +# it should also update x/text later than requested by v1.5.2 +go list -m -f '{{.Path}} {{.Version}}{{if .Indirect}} // indirect{{end}}' all +stdout '^golang.org/x/text [v0-9a-f\.-]+ // indirect' +grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod + +# indirect tag should be removed upon seeing direct import +cp $WORK/tmp/usetext.go x.go +go list +grep 'rsc.io/quote v1.5.2$' go.mod +grep 'golang.org/x/text [v0-9a-f\.-]+$' go.mod + +# indirect tag should be added by go mod -sync +cp $WORK/tmp/usequote.go x.go +go mod -sync +grep 'rsc.io/quote v1.5.2$' go.mod +grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod + +# requirement should be dropped entirely if not needed +cp $WORK/tmp/usetext.go x.go +go mod -sync +! grep rsc.io/quote go.mod +grep 'golang.org/x/text [v0-9a-f\.-]+$' go.mod + +-- go.mod -- +module x +require rsc.io/quote v1.5.1 +-- x.go -- +package x +-- $WORK/tmp/usetext.go -- +package x +import _ "golang.org/x/text" +-- $WORK/tmp/usequote.go -- +package x +import _ "rsc.io/quote" diff --git a/src/cmd/go/testdata/script/mod_get_upgrade.txt b/src/cmd/go/testdata/script/mod_get_upgrade.txt new file mode 100644 index 0000000000..5eb5ff9657 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_upgrade.txt @@ -0,0 +1,41 @@ +env GO111MODULE=on + +go get rsc.io/quote@v1.5.1 +go list -m all +stdout 'rsc.io/quote v1.5.1' +grep 'rsc.io/quote v1.5.1$' go.mod + +# get -u should update all dependencies +go get -u +grep 'rsc.io/quote v1.5.2$' go.mod +grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod + +# get -u rsc.io/sampler should update only sampler's dependencies +cp go.mod-v1.5.1 go.mod +go get -u rsc.io/sampler +grep 'rsc.io/quote v1.5.1$' go.mod +grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod + +# move to a pseudo-version after any tags +go get -m rsc.io/quote@dd9747d +grep 'rsc.io/quote v0.0.0-20180628003336-dd9747d19b04' go.mod + +# get -u should not jump off newer pseudo-version to earlier tag +go get -m -u +grep 'rsc.io/quote v0.0.0-20180628003336-dd9747d19b04' go.mod + +# move to earlier pseudo-version +go get -m rsc.io/quote@e7a685a342 +grep 'rsc.io/quote v0.0.0-20180214005133-e7a685a342c0' go.mod + +# get -u should jump off earlier pseudo-version to newer tag +go get -m -u +grep 'rsc.io/quote v1.5.2' go.mod + +-- go.mod -- +module x +require rsc.io/quote v1.1.0 + +-- go.mod-v1.5.1 -- +module x +require rsc.io/quote v1.5.1 diff --git a/src/cmd/go/testdata/script/mod_getmode_vendor.txt b/src/cmd/go/testdata/script/mod_getmode_vendor.txt new file mode 100644 index 0000000000..861e91c4e2 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_getmode_vendor.txt @@ -0,0 +1,23 @@ +env GO111MODULE=on + +go get -m rsc.io/quote@v1.5.1 +go mod -vendor +env GOPATH=$WORK/empty +env GOPROXY=file:///nonexist + +go list -getmode=vendor +go list -getmode=vendor -m -f '{{.Path}} {{.Version}} {{.Dir}}' all +stdout '^rsc.io/quote v1.5.1 .*vendor[\\/]rsc.io[\\/]quote$' +stdout '^golang.org/x/text v0.0.0.* .*vendor[\\/]golang.org[\\/]x[\\/]text$' + +! go list -getmode=vendor -m rsc.io/quote@latest +stderr 'module lookup disabled by -getmode=vendor' +! go get -getmode=vendor -u +stderr 'go get: disabled by -getmode=vendor' + +-- go.mod -- +module x + +-- x.go -- +package x +import _ "rsc.io/quote" diff --git a/src/cmd/go/testdata/script/mod_import.txt b/src/cmd/go/testdata/script/mod_import.txt new file mode 100644 index 0000000000..3985b43144 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_import.txt @@ -0,0 +1,18 @@ +env GO111MODULE=on + +# latest rsc.io/quote should be v1.5.2 not v1.5.3-pre1 +go list +go list -m all +stdout 'rsc.io/quote v1.5.2' + +# but v1.5.3-pre1 should be a known version +go list -m -versions rsc.io/quote +stdout '^rsc.io/quote v1.0.0 v1.1.0 v1.2.0 v1.2.1 v1.3.0 v1.4.0 v1.5.0 v1.5.1 v1.5.2 v1.5.3-pre1$' + +-- go.mod -- +module x + +-- x.go -- +package x +import _ "rsc.io/quote" + diff --git a/src/cmd/go/testdata/script/mod_list_upgrade.txt b/src/cmd/go/testdata/script/mod_list_upgrade.txt new file mode 100644 index 0000000000..474df0dc26 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_list_upgrade.txt @@ -0,0 +1,8 @@ +env GO111MODULE=on + +go list -m -u all +stdout 'rsc.io/quote v1.2.0 \[v1\.5\.2\]' + +-- go.mod -- +module x +require rsc.io/quote v1.2.0 diff --git a/src/cmd/go/testdata/script/mod_multirepo.txt b/src/cmd/go/testdata/script/mod_multirepo.txt new file mode 100644 index 0000000000..74d952cca0 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_multirepo.txt @@ -0,0 +1,40 @@ +env GO111MODULE=on + +# initial standalone module should use no downloaded modules +go list -deps -f {{.Dir}} +! stdout 'src[\\/]mod' + +# v2 import should use a downloaded module +# both without an explicit go.mod entry ... +cp tmp/use_v2.go x.go +go list -deps -f {{.Dir}} +stdout 'src[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$' + +# ... and with one ... +cp tmp/use_v2.mod go.mod +go list -deps -f {{.Dir}} +stdout 'src[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$' + +# ... and even if there is a v2 module in a subdirectory. +mkdir v2 +cp x.go v2/x.go +cp tmp/v2.mod v2/go.mod +go list -deps -f {{.Dir}} +stdout 'src[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$' + +-- go.mod -- +module rsc.io/quote + +-- x.go -- +package quote + +-- tmp/use_v2.go -- +package quote +import _ "rsc.io/quote/v2" + +-- tmp/use_v2.mod -- +module rsc.io/quote +require rsc.io/quote/v2 v2.0.1 + +-- tmp/v2.mod -- +package rsc.io/quote/v2 diff --git a/src/cmd/go/testdata/script/mod_query.txt b/src/cmd/go/testdata/script/mod_query.txt new file mode 100644 index 0000000000..4baaaa89ed --- /dev/null +++ b/src/cmd/go/testdata/script/mod_query.txt @@ -0,0 +1,24 @@ +env GO111MODULE=on + +go list -m -versions rsc.io/quote +stdout '^rsc.io/quote v1.0.0 v1.1.0 v1.2.0 v1.2.1 v1.3.0 v1.4.0 v1.5.0 v1.5.1 v1.5.2 v1.5.3-pre1$' + +# latest rsc.io/quote should be v1.5.2 not v1.5.3-pre1 +go list -m rsc.io/quote@latest +stdout 'rsc.io/quote v1.5.2$' + +go list -m rsc.io/quote@>v1.5.2 +stdout 'rsc.io/quote v1.5.3-pre1$' + +go list -m rsc.io/quote@v1.5.3 +stderr 'go list -m rsc.io/quote: no matching versions for query ">v1.5.3"' + +go list -m -e -f '{{.Error.Err}}' rsc.io/quote@>v1.5.3 +stdout 'no matching versions for query ">v1.5.3"' + +-- go.mod -- +module x +require rsc.io/quote v1.0.0 diff --git a/src/cmd/go/testdata/script/mod_upgrade_patch.txt b/src/cmd/go/testdata/script/mod_upgrade_patch.txt new file mode 100644 index 0000000000..3c27cdbf7b --- /dev/null +++ b/src/cmd/go/testdata/script/mod_upgrade_patch.txt @@ -0,0 +1,29 @@ +env GO111MODULE=on + +go list -m all +stdout '^rsc.io/quote v1.4.0' +stdout '^rsc.io/sampler v1.0.0' + +# get -u=patch rsc.io/quote should take latest quote & patch update its deps +go get -m -u=patch rsc.io/quote +go list -m all +stdout '^rsc.io/quote v1.5.2' +stdout '^rsc.io/sampler v1.3.1' +stdout '^golang.org/x/text v0.0.0-' + +# get -u=patch quote@v1.2.0 should take that version of quote & patch update its deps +go get -m -u=patch rsc.io/quote@v1.2.0 +go list -m all +stdout '^rsc.io/quote v1.2.0' +stdout '^rsc.io/sampler v1.3.1' +stdout '^golang.org/x/text v0.0.0-' + +# get -u=patch with no args applies to all deps +go get -m -u=patch +go list -m all +stdout '^rsc.io/quote v1.2.1' + +-- go.mod -- +module x +require rsc.io/quote v1.4.0 + -- 2.50.0