2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 22:27:35 +00:00

CI: Fix test for forbidden packages

This commit is contained in:
Alexander Neumann 2017-08-05 12:00:13 +02:00
parent 52c5da997b
commit b557d04007

View File

@ -209,7 +209,7 @@ func (env *TravisEnvironment) RunTests() error {
} }
// check for forbidden imports // check for forbidden imports
deps, err := findImports() deps, err := env.findImports()
if err != nil { if err != nil {
return err return err
} }
@ -310,18 +310,11 @@ func updateEnv(env []string, override map[string]string) []string {
return newEnv return newEnv
} }
func findImports() (map[string][]string, error) { func (env *TravisEnvironment) findImports() (map[string][]string, error) {
res := make(map[string][]string) res := make(map[string][]string)
cwd, err := os.Getwd() cmd := exec.Command("go", "list", "-f", `{{.ImportPath}} {{join .Imports " "}}`, "./internal/...", "./cmd/...")
if err != nil { cmd.Env = updateEnv(os.Environ(), env.env)
return nil, fmt.Errorf("Getwd() returned error: %v", err)
}
gopath := cwd + ":" + filepath.Join(cwd, "vendor")
cmd := exec.Command("go", "list", "-f", `{{.ImportPath}} {{join .Imports " "}}`, "./src/...")
cmd.Env = updateEnv(os.Environ(), map[string]string{"GOPATH": gopath})
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
output, err := cmd.Output() output, err := cmd.Output()