diff --git a/cmd/dep/integration_test.go b/cmd/dep/integration_test.go index ca2e018f6b..ba4cbc87c8 100644 --- a/cmd/dep/integration_test.go +++ b/cmd/dep/integration_test.go @@ -37,13 +37,13 @@ func TestIntegration(t *testing.T) { defer testProj.Cleanup() // Create and checkout the vendor revisions - for ip, rev := range testCase.InitialVendors { + for ip, rev := range testCase.VendorInitial { testProj.GetVendorGit(ip) testProj.RunGit(testProj.VendorPath(ip), "checkout", rev) } // Create and checkout the import revisions - for ip, rev := range testCase.Imports { + for ip, rev := range testCase.GopathInitial { testProj.RunGo("get", ip) testProj.RunGit(testProj.Path("src", ip), "checkout", rev) } diff --git a/cmd/dep/remove_test.go b/cmd/dep/remove_test.go index 19d195ba24..561464a225 100644 --- a/cmd/dep/remove_test.go +++ b/cmd/dep/remove_test.go @@ -21,13 +21,13 @@ func TestRemoveErrors(t *testing.T) { defer testProj.Cleanup() // Create and checkout the vendor revisions - for ip, rev := range testCase.InitialVendors { + for ip, rev := range testCase.VendorInitial { testProj.GetVendorGit(ip) testProj.RunGit(testProj.VendorPath(ip), "checkout", rev) } // Create and checkout the import revisions - for ip, rev := range testCase.Imports { + for ip, rev := range testCase.GopathInitial { testProj.RunGo("get", ip) testProj.RunGit(testProj.Path("src", ip), "checkout", rev) } diff --git a/cmd/dep/testdata/harness_tests/README.md b/cmd/dep/testdata/harness_tests/README.md index 3941247231..a34d68d186 100644 --- a/cmd/dep/testdata/harness_tests/README.md +++ b/cmd/dep/testdata/harness_tests/README.md @@ -27,7 +27,7 @@ desired. The test name will consist of the directory path from `testdata` to the test case directory itself. In the above example, the test name would be `category1/subcategory1/case1`, and could be singled out with the `-run` option of `go test` (i.e. -`go test github.com/golang/dep/cmp/dep -run Integration/category1/subcategory1/case1`). +`go test github.com/golang/dep/cmp/dep -run Integration/category1/subcategory1/case1`). New tests can be added simply by adding a new directory with the json file to the `testdata` tree. There is no need for code modification - the new test will be included automatically. @@ -44,15 +44,15 @@ The `testcase.json` file has the following format: ["init"], ["ensure", "github.com/sdboyer/deptesttres"] ], - "imports": { + "gopath-initial": { "github.com/sdboyer/deptest": "v0.8.0", "github.com/sdboyer/deptestdos": "a0196baa11ea047dd65037287451d36b861b00ea" }, - "initialVendors": { + "vendor-initial": { "github.com/sdboyer/deptesttres": "v2.1.0", "github.com/sdboyer/deptestquatro": "cf596baa11ea047ddf8797287451d36b861bab45" }, - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos", "github.com/sdboyer/deptesttres", @@ -65,15 +65,15 @@ for example, it can be completely left out. The test procedure is as follows: -1. Create a temporary directory for the test project environment -2. Create `src/github.com/golang/notexist` as the project -3. Copy the contents of `initial` to the project -4. Fetch the repos and versions in `imports` to the `src` directory -5. Fetch the repos and versions in `initialVendors` to the `vendor` directory -6. Run the commands in `commands` in order on the project -7. Check the resulting files against those in `final` -8. Check the `vendor` directory for the repos listed under `finalVendors` +1. Create a unique temporary directory (TMPDIR) as the test run's GOPATH +2. Create `$TMPDIR/src/github.com/golang/notexist` as the current project +3. Copy the contents of `initial` input directory to the project +4. Fetch the repos and versions in `gopath-initial` into `$TMPDIR/src` directory +5. Fetch the repos and versions in `vendor-initial` to the project's `vendor` directory +6. Run `commands` on the project, in declaration order +7. Check the resulting files against those in the `final` input directory +8. Check the `vendor` directory for the projects listed under `vendor-final` 9. Check that there were no changes to `src` listings -10. Clean up +10. Clean up Note that for the remote fetches, only git repos are currently supported. diff --git a/cmd/dep/testdata/harness_tests/ensure/empty/case1/testcase.json b/cmd/dep/testdata/harness_tests/ensure/empty/case1/testcase.json index 5fa2d5ab4d..515a342de3 100644 --- a/cmd/dep/testdata/harness_tests/ensure/empty/case1/testcase.json +++ b/cmd/dep/testdata/harness_tests/ensure/empty/case1/testcase.json @@ -3,7 +3,7 @@ ["init"], ["ensure", "-update"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest" ] } diff --git a/cmd/dep/testdata/harness_tests/ensure/empty/case2/testcase.json b/cmd/dep/testdata/harness_tests/ensure/empty/case2/testcase.json index 3e47888d0b..19da527090 100644 --- a/cmd/dep/testdata/harness_tests/ensure/empty/case2/testcase.json +++ b/cmd/dep/testdata/harness_tests/ensure/empty/case2/testcase.json @@ -2,7 +2,7 @@ "commands": [ ["ensure"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest" ] } diff --git a/cmd/dep/testdata/harness_tests/ensure/override/case1/testcase.json b/cmd/dep/testdata/harness_tests/ensure/override/case1/testcase.json index 56750c3410..c66b07ff04 100644 --- a/cmd/dep/testdata/harness_tests/ensure/override/case1/testcase.json +++ b/cmd/dep/testdata/harness_tests/ensure/override/case1/testcase.json @@ -3,7 +3,7 @@ ["init"], ["ensure", "-override", "github.com/sdboyer/deptest@1.0.0"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest" ] } diff --git a/cmd/dep/testdata/harness_tests/ensure/update/case1/testcase.json b/cmd/dep/testdata/harness_tests/ensure/update/case1/testcase.json index 411a139faf..32da9821de 100644 --- a/cmd/dep/testdata/harness_tests/ensure/update/case1/testcase.json +++ b/cmd/dep/testdata/harness_tests/ensure/update/case1/testcase.json @@ -3,7 +3,7 @@ ["init"], ["ensure", "-update", "github.com/sdboyer/deptest"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos" ] diff --git a/cmd/dep/testdata/harness_tests/init/case1/testcase.json b/cmd/dep/testdata/harness_tests/init/case1/testcase.json index c7f39ea9a3..c449f86949 100644 --- a/cmd/dep/testdata/harness_tests/init/case1/testcase.json +++ b/cmd/dep/testdata/harness_tests/init/case1/testcase.json @@ -2,11 +2,11 @@ "commands": [ ["init"] ], - "imports": { + "gopath-initial": { "github.com/sdboyer/deptest": "v0.8.0", "github.com/sdboyer/deptestdos": "a0196baa11ea047dd65037287451d36b861b00ea" }, - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos" ] diff --git a/cmd/dep/testdata/harness_tests/init/case2/testcase.json b/cmd/dep/testdata/harness_tests/init/case2/testcase.json index 867d4237cd..a2099b17de 100644 --- a/cmd/dep/testdata/harness_tests/init/case2/testcase.json +++ b/cmd/dep/testdata/harness_tests/init/case2/testcase.json @@ -2,10 +2,10 @@ "commands": [ ["init"] ], - "imports": { + "gopath-initial": { "github.com/sdboyer/deptest": "v0.8.0" }, - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos" ] diff --git a/cmd/dep/testdata/harness_tests/init/case3/testcase.json b/cmd/dep/testdata/harness_tests/init/case3/testcase.json index 53b48d9d14..9974fa1515 100644 --- a/cmd/dep/testdata/harness_tests/init/case3/testcase.json +++ b/cmd/dep/testdata/harness_tests/init/case3/testcase.json @@ -2,10 +2,10 @@ "commands": [ ["init"] ], - "imports": { + "gopath-initial": { "github.com/sdboyer/deptestdos": "a0196baa11ea047dd65037287451d36b861b00ea" }, - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos" ] diff --git a/cmd/dep/testdata/harness_tests/init/skip-hidden/testcase.json b/cmd/dep/testdata/harness_tests/init/skip-hidden/testcase.json index bb3978e595..18dcb9a514 100644 --- a/cmd/dep/testdata/harness_tests/init/skip-hidden/testcase.json +++ b/cmd/dep/testdata/harness_tests/init/skip-hidden/testcase.json @@ -2,7 +2,7 @@ "commands": [ ["init"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest" ] } diff --git a/cmd/dep/testdata/harness_tests/remove/force/case1/testcase.json b/cmd/dep/testdata/harness_tests/remove/force/case1/testcase.json index ba68a999b4..84447c9b42 100644 --- a/cmd/dep/testdata/harness_tests/remove/force/case1/testcase.json +++ b/cmd/dep/testdata/harness_tests/remove/force/case1/testcase.json @@ -2,7 +2,7 @@ "commands": [ ["remove", "-force", "github.com/sdboyer/deptestdos", "github.com/not/used"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos" ] diff --git a/cmd/dep/testdata/harness_tests/remove/specific/case1/testcase.json b/cmd/dep/testdata/harness_tests/remove/specific/case1/testcase.json index 9e49a42aac..327867d481 100644 --- a/cmd/dep/testdata/harness_tests/remove/specific/case1/testcase.json +++ b/cmd/dep/testdata/harness_tests/remove/specific/case1/testcase.json @@ -2,7 +2,7 @@ "commands": [ ["remove", "github.com/not/used"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos" ] diff --git a/cmd/dep/testdata/harness_tests/remove/specific/case2/testcase.json b/cmd/dep/testdata/harness_tests/remove/specific/case2/testcase.json index 6a13adac9e..1a5f806b6c 100644 --- a/cmd/dep/testdata/harness_tests/remove/specific/case2/testcase.json +++ b/cmd/dep/testdata/harness_tests/remove/specific/case2/testcase.json @@ -2,11 +2,11 @@ "commands": [ ["remove", "github.com/not/used"] ], - "initialVendors": { + "vendor-initial": { "github.com/sdboyer/deptest": "v0.8.0", "github.com/sdboyer/deptestdos": "a0196baa11ea047dd65037287451d36b861b00ea" }, - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest" ] } diff --git a/cmd/dep/testdata/harness_tests/remove/unused/case1/testcase.json b/cmd/dep/testdata/harness_tests/remove/unused/case1/testcase.json index 2d4e95e1e2..23cc6142a5 100644 --- a/cmd/dep/testdata/harness_tests/remove/unused/case1/testcase.json +++ b/cmd/dep/testdata/harness_tests/remove/unused/case1/testcase.json @@ -2,7 +2,7 @@ "commands": [ ["remove", "-unused"] ], - "finalVendors": [ + "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos" ] diff --git a/test/integration_testcase.go b/test/integration_testcase.go index a4aa888817..8c10e434a7 100644 --- a/test/integration_testcase.go +++ b/test/integration_testcase.go @@ -19,15 +19,15 @@ var ( // IntegrationTestCase manages a test case directory structure and content type IntegrationTestCase struct { - t *testing.T - Name string - RootPath string - InitialPath string - FinalPath string - Commands [][]string `json:"commands"` - Imports map[string]string `json:"imports"` - InitialVendors map[string]string `json:"initialVendors"` - FinalVendors []string `json:"finalVendors"` + t *testing.T + Name string + RootPath string + InitialPath string + FinalPath string + Commands [][]string `json:"commands"` + GopathInitial map[string]string `json:"gopath-initial"` + VendorInitial map[string]string `json:"vendor-initial"` + VendorFinal []string `json:"vendor-final"` } func NewTestCase(t *testing.T, name string) *IntegrationTestCase { @@ -97,7 +97,7 @@ func (tc *IntegrationTestCase) CompareFile(goldenPath, working string) { } func (tc *IntegrationTestCase) CompareVendorPaths(gotVendorPaths []string) { - wantVendorPaths := tc.FinalVendors + wantVendorPaths := tc.VendorFinal if len(gotVendorPaths) != len(wantVendorPaths) { tc.t.Fatalf("Wrong number of vendor paths created: want %d got %d", len(wantVendorPaths), len(gotVendorPaths)) }