diff --git a/cmd/dep/testdata/harness_tests/init/glide/case4/README.md b/cmd/dep/testdata/harness_tests/init/glide/case4/README.md new file mode 100644 index 0000000000..912e40844f --- /dev/null +++ b/cmd/dep/testdata/harness_tests/init/glide/case4/README.md @@ -0,0 +1 @@ +Ignore glide config if glide.yaml is malformed and cannot be parsed correctly. diff --git a/cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.lock b/cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.lock new file mode 100644 index 0000000000..1aadf7f962 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.lock @@ -0,0 +1,21 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "github.com/sdboyer/deptest" + packages = ["."] + revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" + version = "v1.0.0" + +[[projects]] + name = "github.com/sdboyer/deptestdos" + packages = ["."] + revision = "5c607206be5decd28e6263ffffdcee067266015e" + version = "v2.0.0" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "1ed417a0bec57ffe988fae1cba8f3d49994fb893394d61844e0b3c96d69573fe" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.toml new file mode 100644 index 0000000000..aaf78303fa --- /dev/null +++ b/cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.toml @@ -0,0 +1,4 @@ + +[[constraint]] + name = "github.com/sdboyer/deptestdos" + version = "2.0.0" diff --git a/cmd/dep/testdata/harness_tests/init/glide/case4/initial/glide.yaml b/cmd/dep/testdata/harness_tests/init/glide/case4/initial/glide.yaml new file mode 100644 index 0000000000..a9c8e891fb --- /dev/null +++ b/cmd/dep/testdata/harness_tests/init/glide/case4/initial/glide.yaml @@ -0,0 +1,20 @@ +'package: github.com/golang/notexist +homepage: http://example.com +license: MIT +owners: +- name: Sam Boyer + email: sdboyer@example.com + homepage: http://sdboyer.io +ignore: +- github.com/sdboyer/dep-test +excludeDirs: +- samples +import: +- package: github.com/sdboyer/deptest # This is a transitive dep and will be ignored + repo: https://github.com/sdboyer/deptest.git + vcs: git + version: v1.0.0 +- package: github.com/sdboyer/deptestdos + version: v2.0.0 +testImport: +- package: github.com/golang/lint diff --git a/cmd/dep/testdata/harness_tests/init/glide/case4/initial/main.go b/cmd/dep/testdata/harness_tests/init/glide/case4/initial/main.go new file mode 100644 index 0000000000..2b2c7c396e --- /dev/null +++ b/cmd/dep/testdata/harness_tests/init/glide/case4/initial/main.go @@ -0,0 +1,16 @@ +// 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 ( + "fmt" + + "github.com/sdboyer/deptestdos" +) + +func main() { + var x deptestdos.Bar + fmt.Println(x) +} diff --git a/cmd/dep/testdata/harness_tests/init/glide/case4/testcase.json b/cmd/dep/testdata/harness_tests/init/glide/case4/testcase.json new file mode 100644 index 0000000000..85a05ed658 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/init/glide/case4/testcase.json @@ -0,0 +1,14 @@ +{ + "commands": [ + ["init", "-no-examples"] + ], + "error-expected": "", + "gopath-initial": { + "github.com/sdboyer/deptest": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f", + "github.com/sdboyer/deptestdos": "5c607206be5decd28e6263ffffdcee067266015e" + }, + "vendor-final": [ + "github.com/sdboyer/deptest", + "github.com/sdboyer/deptestdos" + ] +} diff --git a/internal/importers/base/importer_test.go b/internal/importers/base/importer_test.go index 0a0a556379..51e44e25be 100644 --- a/internal/importers/base/importer_test.go +++ b/internal/importers/base/importer_test.go @@ -5,6 +5,7 @@ package base import ( + "fmt" "log" "testing" @@ -399,6 +400,32 @@ func TestBaseImporter_ImportProjects(t *testing.T) { }, }, }, + "invalid project root": { + importertest.TestCase{ + WantSourceRepo: "", + WantWarning: "Warning: Skipping project. Cannot determine the project root for invalid-project", + }, + []ImportedPackage{ + { + Name: "invalid-project", + }, + }, + }, + "nonexistent project": { + importertest.TestCase{ + WantSourceRepo: "", + WantWarning: fmt.Sprintf( + "Warning: Unable to apply constraint %q for %s", + importertest.V1Tag, importertest.NonexistentPrj, + ), + }, + []ImportedPackage{ + { + Name: importertest.NonexistentPrj, + LockHint: importertest.V1Tag, + }, + }, + }, } for name, tc := range testcases { diff --git a/internal/importers/importertest/testdata.go b/internal/importers/importertest/testdata.go index cd7f2c0879..fc037ff0dd 100644 --- a/internal/importers/importertest/testdata.go +++ b/internal/importers/importertest/testdata.go @@ -61,4 +61,7 @@ const ( // MultiTaggedPlainTag is a non-semver tag on MultiTaggedRev. MultiTaggedPlainTag = "stable" + + // NonexistentPrj is a dummy project which does not exist on Github. + NonexistentPrj = "github.com/nonexistent/project" )