diff --git a/appveyor.yml b/appveyor.yml index 8a35181..3aa1f56 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,6 +18,7 @@ build_script: - go build test_script: -- PATH=$GOPATH/bin:$PATH go test . +- set PATH=%PATH%;%GOPATH%\bin +- go test . deploy: off diff --git a/gvc.go b/gvc.go index 3ea33aa..f381a94 100644 --- a/gvc.go +++ b/gvc.go @@ -131,6 +131,9 @@ func cleanup(path string) error { } else { packages, err = glideListImports(path) } + if err != nil { + return err + } // The package list already have the path converted to the os specific // path separator, needed for future comparisons. @@ -187,7 +190,7 @@ func cleanup(path string) error { keep := false for _, name := range pkgList { - // If a directory is a needed package then keep it + // if a directory is a needed package then keep it keep = keep || info.IsDir() && name == lastVendorPath // The remaining tests are only for files @@ -291,11 +294,11 @@ func getLastVendorPath(path string) (string, error) { } func isParentDirectory(parent, child string) bool { - if !strings.HasSuffix(parent, "/") { - parent += "/" + if !strings.HasSuffix(parent, string(filepath.Separator)) { + parent += string(filepath.Separator) } - if !strings.HasSuffix(child, "/") { - child += "/" + if !strings.HasSuffix(child, string(filepath.Separator)) { + child += string(filepath.Separator) } return strings.HasPrefix(child, parent) } diff --git a/gvc_test.go b/gvc_test.go index 3e9043c..9713766 100644 --- a/gvc_test.go +++ b/gvc_test.go @@ -442,11 +442,11 @@ func TestGetLastVendorPath(t *testing.T) { } for input, expected := range tests { - got, err := getLastVendorPath(input) + got, err := getLastVendorPath(filepath.FromSlash(input)) if err != nil { t.Fatalf("Unexpected error: %v", err) } - if got != expected { + if got != filepath.FromSlash(expected) { t.Fatalf("got=%q, expected=%q", got, expected) } } @@ -467,9 +467,9 @@ func TestIsParentDirectory(t *testing.T) { } for input, expected := range tests { - got := isParentDirectory(input.Parent, input.Child) + got := isParentDirectory(filepath.FromSlash(input.Parent), filepath.FromSlash(input.Child)) if got != expected { - t.Fatalf("got=%q, expected=%q", got, expected) + t.Fatalf("got=%t, expected=%t", got, expected) } } }