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:
parent
52c5da997b
commit
b557d04007
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user