From 5fe99bcfaf78658924e68771aeff9fe18b60e75f Mon Sep 17 00:00:00 2001 From: Jacky Chiu Date: Fri, 29 Dec 2017 13:10:33 -0500 Subject: [PATCH 1/3] cleaned up tests with test dir --- cmd/dep/status_test.go | 20 ++++++------------- .../status/collect_constraints/main.go | 10 ++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 cmd/dep/testdata/status/collect_constraints/main.go diff --git a/cmd/dep/status_test.go b/cmd/dep/status_test.go index 09c9862740..3fd16f2370 100644 --- a/cmd/dep/status_test.go +++ b/cmd/dep/status_test.go @@ -407,23 +407,15 @@ func TestCollectConstraints(t *testing.T) { h := test.NewHelper(t) defer h.Cleanup() - h.TempDir("src") - pwd := h.Path(".") - h.TempFile(filepath.Join("src", "dep.go"), ` - package dep - import ( - _ "github.com/boltdb/bolt" - _ "github.com/sdboyer/deptest" - _ "github.com/sdboyer/dep-test" - _ "github.com/sdboyer/deptestdos" - ) - type FooBar int - `) + testdir := filepath.Join("src", "collect_constraints_test") + h.TempDir(testdir) + h.TempCopy(filepath.Join(testdir, "main.go"), "status/collect_constraints/main.go") + testProjPath := h.Path(testdir) discardLogger := log.New(ioutil.Discard, "", 0) ctx := &dep.Ctx{ - GOPATH: pwd, + GOPATH: testProjPath, Out: discardLogger, Err: discardLogger, } @@ -435,7 +427,7 @@ func TestCollectConstraints(t *testing.T) { // Create new project and set root. Setting root is required for PackageList // to run properly. p := new(dep.Project) - p.SetRoot(filepath.Join(pwd, "src")) + p.SetRoot(testProjPath) for _, c := range cases { t.Run(c.name, func(t *testing.T) { diff --git a/cmd/dep/testdata/status/collect_constraints/main.go b/cmd/dep/testdata/status/collect_constraints/main.go new file mode 100644 index 0000000000..5d84a93bc8 --- /dev/null +++ b/cmd/dep/testdata/status/collect_constraints/main.go @@ -0,0 +1,10 @@ +package main + +import ( + _ "github.com/boltdb/bolt" + _ "github.com/sdboyer/dep-test" + _ "github.com/sdboyer/deptest" + _ "github.com/sdboyer/deptestdos" +) + +type FooBar int From 678982b72fe053f82b544b86022956bed7a1811d Mon Sep 17 00:00:00 2001 From: Jacky Chiu Date: Fri, 29 Dec 2017 13:26:47 -0500 Subject: [PATCH 2/3] Add licence --- cmd/dep/testdata/status/collect_constraints/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/dep/testdata/status/collect_constraints/main.go b/cmd/dep/testdata/status/collect_constraints/main.go index 5d84a93bc8..a53da1fd2e 100644 --- a/cmd/dep/testdata/status/collect_constraints/main.go +++ b/cmd/dep/testdata/status/collect_constraints/main.go @@ -1,3 +1,7 @@ +// Copyright 2017 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 ( From 05dae17de9d16e7db005520be0450352e3ab96ab Mon Sep 17 00:00:00 2001 From: Jacky Chiu Date: Fri, 29 Dec 2017 13:50:41 -0500 Subject: [PATCH 3/3] Filepath join to test src as well --- cmd/dep/status_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dep/status_test.go b/cmd/dep/status_test.go index 3fd16f2370..d18f9404ea 100644 --- a/cmd/dep/status_test.go +++ b/cmd/dep/status_test.go @@ -409,7 +409,7 @@ func TestCollectConstraints(t *testing.T) { testdir := filepath.Join("src", "collect_constraints_test") h.TempDir(testdir) - h.TempCopy(filepath.Join(testdir, "main.go"), "status/collect_constraints/main.go") + h.TempCopy(filepath.Join(testdir, "main.go"), filepath.Join("status", "collect_constraints", "main.go")) testProjPath := h.Path(testdir) discardLogger := log.New(ioutil.Discard, "", 0)