From 6e8e56ee9e8ba4555ec00691aceffa87f2b1d8ed Mon Sep 17 00:00:00 2001 From: Miguel Perez Date: Thu, 28 Sep 2017 23:11:55 -0400 Subject: [PATCH 1/2] cmd/dep: make out-of-sync ensure less strict --- cmd/dep/ensure.go | 6 ++---- .../errs => add}/desync/final/Gopkg.lock | 14 +++++++++---- .../ensure/add/desync/final/Gopkg.toml | 6 ++++++ .../add/{errs => }/desync/final/main.go | 0 .../ensure/add/desync/initial/Gopkg.lock | 15 +++++++++++++ .../final => desync/initial}/Gopkg.toml | 0 .../errs => add}/desync/initial/main.go | 3 +++ .../ensure/add/desync/stdout.txt | 1 + .../ensure/add/desync/testcase.json | 10 +++++++++ .../ensure/add/errs/desync/testcase.json | 6 ------ .../desync/final}/Gopkg.lock | 10 ++++----- .../desync/final}/Gopkg.toml | 0 .../initial => update/desync/final}/main.go | 0 .../desync/initial}/Gopkg.lock | 0 .../final => desync/initial}/Gopkg.toml | 0 .../desync/final => desync/initial}/main.go | 0 .../ensure/update/desync/stdout.txt | 1 + .../ensure/update/desync/testcase.json | 9 ++++++++ .../update/errs/desync/initial/Gopkg.lock | 21 ------------------- .../update/errs/desync/initial/Gopkg.toml | 3 --- .../ensure/update/errs/desync/testcase.json | 6 ------ 21 files changed, 62 insertions(+), 49 deletions(-) rename cmd/dep/testdata/harness_tests/ensure/{update/errs => add}/desync/final/Gopkg.lock (65%) create mode 100644 cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.toml rename cmd/dep/testdata/harness_tests/ensure/add/{errs => }/desync/final/main.go (100%) create mode 100644 cmd/dep/testdata/harness_tests/ensure/add/desync/initial/Gopkg.lock rename cmd/dep/testdata/harness_tests/ensure/add/{errs/desync/final => desync/initial}/Gopkg.toml (100%) rename cmd/dep/testdata/harness_tests/ensure/{update/errs => add}/desync/initial/main.go (85%) create mode 100644 cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt create mode 100644 cmd/dep/testdata/harness_tests/ensure/add/desync/testcase.json delete mode 100644 cmd/dep/testdata/harness_tests/ensure/add/errs/desync/testcase.json rename cmd/dep/testdata/harness_tests/ensure/{add/errs/desync/initial => update/desync/final}/Gopkg.lock (85%) rename cmd/dep/testdata/harness_tests/ensure/{add/errs/desync/initial => update/desync/final}/Gopkg.toml (100%) rename cmd/dep/testdata/harness_tests/ensure/{add/errs/desync/initial => update/desync/final}/main.go (100%) rename cmd/dep/testdata/harness_tests/ensure/{add/errs/desync/final => update/desync/initial}/Gopkg.lock (100%) rename cmd/dep/testdata/harness_tests/ensure/update/{errs/desync/final => desync/initial}/Gopkg.toml (100%) rename cmd/dep/testdata/harness_tests/ensure/update/{errs/desync/final => desync/initial}/main.go (100%) create mode 100644 cmd/dep/testdata/harness_tests/ensure/update/desync/stdout.txt create mode 100644 cmd/dep/testdata/harness_tests/ensure/update/desync/testcase.json delete mode 100644 cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.lock delete mode 100644 cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.toml delete mode 100644 cmd/dep/testdata/harness_tests/ensure/update/errs/desync/testcase.json diff --git a/cmd/dep/ensure.go b/cmd/dep/ensure.go index 5fd76cde8c..cfce3cf5ac 100644 --- a/cmd/dep/ensure.go +++ b/cmd/dep/ensure.go @@ -340,9 +340,8 @@ func (cmd *ensureCommand) runUpdate(ctx *dep.Ctx, args []string, p *dep.Project, // user a bit, but the extra effort required is minimal, and it ensures the // user is isolating variables in the event of solve problems (was it the // "pending" changes, or the -update that caused the problem?). - // TODO(sdboyer) reduce this to a warning? if !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) { - return errors.Errorf("%s is out of sync with %s or the project's imports. Run \"dep ensure\" to resync them first before running \"dep ensure -update\"", dep.LockName, dep.ManifestName) + ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName) } // When -update is specified without args, allow every dependency to change @@ -406,9 +405,8 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm // user a bit, but the extra effort required is minimal, and it ensures the // user is isolating variables in the event of solve problems (was it the // "pending" changes, or the -add that caused the problem?). - // TODO(sdboyer) reduce this to a warning? if p.Lock != nil && !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) { - return errors.Errorf("%s is out of sync with %s or the project's imports. Run \"dep ensure\" to resync them first before running \"dep ensure -add\"", dep.LockName, dep.ManifestName) + ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName) } rm, _ := params.RootPackageTree.ToReachMap(true, true, false, p.Manifest.IgnoredPackages()) diff --git a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/Gopkg.lock b/cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.lock similarity index 65% rename from cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/Gopkg.lock rename to cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.lock index 41dd2d4190..a9d0374ee3 100644 --- a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/Gopkg.lock +++ b/cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.lock @@ -3,19 +3,25 @@ [[projects]] name = "github.com/sdboyer/deptest" - version = "v0.8.0" - revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" packages = ["."] + revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" + version = "v1.0.0" [[projects]] name = "github.com/sdboyer/deptestdos" - version = "v2.0.0" + packages = ["."] revision = "5c607206be5decd28e6263ffffdcee067266015e" + version = "v2.0.0" + +[[projects]] + branch = "master" + name = "github.com/sdboyer/deptesttres" packages = ["."] + revision = "54aaeb0023e1f3dcf5f98f31dd8c565457945a12" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "9b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb" + inputs-digest = "86240895e0ee5788e7e8bb56e0d77afd58009a491b69f6835e546db9e5dacfcd" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.toml new file mode 100644 index 0000000000..57787fb45e --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.toml @@ -0,0 +1,6 @@ +[[constraint]] + name = "github.com/sdboyer/deptest" + version = "~0.8.0" +[[constraint]] + branch = "master" + name = "github.com/sdboyer/deptesttres" diff --git a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/final/main.go b/cmd/dep/testdata/harness_tests/ensure/add/desync/final/main.go similarity index 100% rename from cmd/dep/testdata/harness_tests/ensure/add/errs/desync/final/main.go rename to cmd/dep/testdata/harness_tests/ensure/add/desync/final/main.go diff --git a/cmd/dep/testdata/harness_tests/ensure/add/desync/initial/Gopkg.lock b/cmd/dep/testdata/harness_tests/ensure/add/desync/initial/Gopkg.lock new file mode 100644 index 0000000000..2d6f4c0278 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/add/desync/initial/Gopkg.lock @@ -0,0 +1,15 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + name = "github.com/sdboyer/deptesttres" + packages = ["."] + revision = "54aaeb0023e1f3dcf5f98f31dd8c565457945a12" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "9a7bd6944c26792ab2e97fed1227cc402f0cc00465016836efbf04239596dd9f" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/add/desync/initial/Gopkg.toml similarity index 100% rename from cmd/dep/testdata/harness_tests/ensure/add/errs/desync/final/Gopkg.toml rename to cmd/dep/testdata/harness_tests/ensure/add/desync/initial/Gopkg.toml diff --git a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/main.go b/cmd/dep/testdata/harness_tests/ensure/add/desync/initial/main.go similarity index 85% rename from cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/main.go rename to cmd/dep/testdata/harness_tests/ensure/add/desync/initial/main.go index 2eae5b511d..7ad40aca5a 100644 --- a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/main.go +++ b/cmd/dep/testdata/harness_tests/ensure/add/desync/initial/main.go @@ -7,6 +7,7 @@ package main import ( "github.com/sdboyer/deptest" "github.com/sdboyer/deptestdos" + "github.com/sdboyer/deptesttres" ) func main() { @@ -15,4 +16,6 @@ func main() { deptest.Map["yo yo!"] } deptestdos.diMeLo("whatev") + + type a deptesttres.Bar } diff --git a/cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt b/cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt new file mode 100644 index 0000000000..9adb1974eb --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt @@ -0,0 +1 @@ +Warning: Gopkg.lock is out of sync with Gopkg.toml or the project's imports. diff --git a/cmd/dep/testdata/harness_tests/ensure/add/desync/testcase.json b/cmd/dep/testdata/harness_tests/ensure/add/desync/testcase.json new file mode 100644 index 0000000000..eb95e6f16a --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/add/desync/testcase.json @@ -0,0 +1,10 @@ +{ + "commands": [ + ["ensure", "-add", "github.com/sdboyer/deptesttres@master"] + ], + "vendor-final": [ + "github.com/sdboyer/deptest", + "github.com/sdboyer/deptestdos", + "github.com/sdboyer/deptesttres" + ] +} diff --git a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/testcase.json b/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/testcase.json deleted file mode 100644 index 63801ab5df..0000000000 --- a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/testcase.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "commands": [ - ["ensure", "-add", "foobar.com/baz"] - ], - "error-expected": "Gopkg.lock is out of sync with Gopkg.toml or the project's imports. Run \"dep ensure\" to resync them first before running \"dep ensure -add\"" -} diff --git a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/Gopkg.lock b/cmd/dep/testdata/harness_tests/ensure/update/desync/final/Gopkg.lock similarity index 85% rename from cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/Gopkg.lock rename to cmd/dep/testdata/harness_tests/ensure/update/desync/final/Gopkg.lock index 41dd2d4190..1a7b1983f3 100644 --- a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/Gopkg.lock +++ b/cmd/dep/testdata/harness_tests/ensure/update/desync/final/Gopkg.lock @@ -3,19 +3,19 @@ [[projects]] name = "github.com/sdboyer/deptest" - version = "v0.8.0" - revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" packages = ["."] + revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" + version = "v1.0.0" [[projects]] name = "github.com/sdboyer/deptestdos" - version = "v2.0.0" - revision = "5c607206be5decd28e6263ffffdcee067266015e" packages = ["."] + revision = "5c607206be5decd28e6263ffffdcee067266015e" + version = "v2.0.0" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "9b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb" + inputs-digest = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/update/desync/final/Gopkg.toml similarity index 100% rename from cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/Gopkg.toml rename to cmd/dep/testdata/harness_tests/ensure/update/desync/final/Gopkg.toml diff --git a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/main.go b/cmd/dep/testdata/harness_tests/ensure/update/desync/final/main.go similarity index 100% rename from cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/main.go rename to cmd/dep/testdata/harness_tests/ensure/update/desync/final/main.go diff --git a/cmd/dep/testdata/harness_tests/ensure/add/errs/desync/final/Gopkg.lock b/cmd/dep/testdata/harness_tests/ensure/update/desync/initial/Gopkg.lock similarity index 100% rename from cmd/dep/testdata/harness_tests/ensure/add/errs/desync/final/Gopkg.lock rename to cmd/dep/testdata/harness_tests/ensure/update/desync/initial/Gopkg.lock diff --git a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/update/desync/initial/Gopkg.toml similarity index 100% rename from cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/Gopkg.toml rename to cmd/dep/testdata/harness_tests/ensure/update/desync/initial/Gopkg.toml diff --git a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/main.go b/cmd/dep/testdata/harness_tests/ensure/update/desync/initial/main.go similarity index 100% rename from cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/main.go rename to cmd/dep/testdata/harness_tests/ensure/update/desync/initial/main.go diff --git a/cmd/dep/testdata/harness_tests/ensure/update/desync/stdout.txt b/cmd/dep/testdata/harness_tests/ensure/update/desync/stdout.txt new file mode 100644 index 0000000000..9adb1974eb --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/desync/stdout.txt @@ -0,0 +1 @@ +Warning: Gopkg.lock is out of sync with Gopkg.toml or the project's imports. diff --git a/cmd/dep/testdata/harness_tests/ensure/update/desync/testcase.json b/cmd/dep/testdata/harness_tests/ensure/update/desync/testcase.json new file mode 100644 index 0000000000..81a7c2320d --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/desync/testcase.json @@ -0,0 +1,9 @@ +{ + "commands": [ + ["ensure", "-update"] + ], + "vendor-final": [ + "github.com/sdboyer/deptest", + "github.com/sdboyer/deptestdos" + ] +} diff --git a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.lock b/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.lock deleted file mode 100644 index 41dd2d4190..0000000000 --- a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.lock +++ /dev/null @@ -1,21 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/sdboyer/deptest" - version = "v0.8.0" - revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" - packages = ["."] - -[[projects]] - name = "github.com/sdboyer/deptestdos" - version = "v2.0.0" - revision = "5c607206be5decd28e6263ffffdcee067266015e" - packages = ["."] - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "9b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.toml deleted file mode 100644 index 532da96a0d..0000000000 --- a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.toml +++ /dev/null @@ -1,3 +0,0 @@ -[[constraint]] - name = "github.com/sdboyer/deptest" - version = "~0.8.0" \ No newline at end of file diff --git a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/testcase.json b/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/testcase.json deleted file mode 100644 index 99304cff62..0000000000 --- a/cmd/dep/testdata/harness_tests/ensure/update/errs/desync/testcase.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "commands": [ - ["ensure", "-update"] - ], - "error-expected": "Gopkg.lock is out of sync with Gopkg.toml or the project's imports. Run \"dep ensure\" to resync them first before running \"dep ensure -update\"" -} From d5b93beddebad513ca4341d69f4c6a45d52e77e6 Mon Sep 17 00:00:00 2001 From: Miguel Perez Date: Fri, 29 Sep 2017 08:29:18 -0400 Subject: [PATCH 2/2] cmd/dep: fix broken integration test --- cmd/dep/ensure.go | 2 +- cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/dep/ensure.go b/cmd/dep/ensure.go index cfce3cf5ac..a90c8da18d 100644 --- a/cmd/dep/ensure.go +++ b/cmd/dep/ensure.go @@ -477,7 +477,7 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm var wg sync.WaitGroup - fmt.Println("Fetching sources...") + ctx.Out.Println("Fetching sources...") for i, arg := range args { wg.Add(1) diff --git a/cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt b/cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt index 9adb1974eb..c0d7219848 100644 --- a/cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt +++ b/cmd/dep/testdata/harness_tests/ensure/add/desync/stdout.txt @@ -1 +1,2 @@ Warning: Gopkg.lock is out of sync with Gopkg.toml or the project's imports. +Fetching sources...