2020-01-31 23:58:10 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2020-02-01 22:14:20 +00:00
|
|
|
// listTestFiles returns absolute paths for all _test.go files of the package
|
|
|
|
// including the ones with "private" build tag.
|
2020-01-31 23:58:10 +00:00
|
|
|
func listTestFiles(rootPackage string) []string {
|
|
|
|
files := getPackageFiles(rootPackage, []string{"-tags", "private"})
|
|
|
|
var tests []string
|
|
|
|
for f := range files {
|
|
|
|
if strings.HasSuffix(f, "_test.go") {
|
|
|
|
tests = append(tests, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(tests)
|
|
|
|
return tests
|
|
|
|
}
|
|
|
|
|
2020-02-01 22:14:20 +00:00
|
|
|
// listProtectedFiles returns absolute paths for all files of the package
|
|
|
|
// protected by "!change" build tag.
|
2020-01-31 23:58:10 +00:00
|
|
|
func listProtectedFiles(rootPackage string) []string {
|
|
|
|
allFiles := getPackageFiles(rootPackage, nil)
|
|
|
|
allFilesWithoutProtected := getPackageFiles(rootPackage, []string{"-tags", "change"})
|
|
|
|
|
|
|
|
var protectedFiles []string
|
|
|
|
for f := range allFiles {
|
|
|
|
if _, ok := allFilesWithoutProtected[f]; !ok {
|
|
|
|
protectedFiles = append(protectedFiles, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(protectedFiles)
|
|
|
|
return protectedFiles
|
|
|
|
}
|
|
|
|
|
2020-02-01 22:14:20 +00:00
|
|
|
// listPrivateFiles returns absolute paths for all files of the package
|
|
|
|
// protected by "private,solution" build tag.
|
2020-01-31 23:58:10 +00:00
|
|
|
func listPrivateFiles(rootPackage string) []string {
|
|
|
|
allFiles := getPackageFiles(rootPackage, []string{})
|
|
|
|
allWithPrivate := getPackageFiles(rootPackage, []string{"-tags", "private,solution"})
|
|
|
|
|
|
|
|
var files []string
|
|
|
|
for f := range allWithPrivate {
|
|
|
|
if _, isPublic := allFiles[f]; !isPublic {
|
|
|
|
files = append(files, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(files)
|
|
|
|
return files
|
2020-02-01 22:14:20 +00:00
|
|
|
}
|