Skip to content

Commit

Permalink
Merge pull request #488 from CtrlZvi/ignore_testdata_packages
Browse files Browse the repository at this point in the history
Stop compiling and testing packages in testdata
  • Loading branch information
riannucci committed Apr 27, 2021
2 parents c1c3b7b + 6205260 commit 0fc5ef5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions goconvey.go
Expand Up @@ -126,6 +126,9 @@ func runTestOnUpdates(queue chan messaging.Folders, executor contract.Executor,
func extractPackages(folderList messaging.Folders) []*contract.Package {
packageList := []*contract.Package{}
for _, folder := range folderList {
if isInsideTestdata(folder) {
continue
}
hasImportCycle := testFilesImportTheirOwnPackage(folder.Path)
packageName := resolvePackageName(folder.Path)
packageList = append(
Expand All @@ -136,6 +139,28 @@ func extractPackages(folderList messaging.Folders) []*contract.Package {
return packageList
}

// For packages that operate on Go source code files, such as Go tooling, it is
// important to have a location that will not be considered part of package
// source to store those files. The official Go tooling selected the testdata
// folder for this purpose, so we need to ignore folders inside testdata.
func isInsideTestdata(folder *messaging.Folder) bool {
relativePath, err := filepath.Rel(folder.Root, folder.Path)
if err != nil {
// There should never be a folder that's not inside the root, but if
// there is, we can presumably count it as outside a testdata folder as
// well
return false
}

for _, directory := range strings.Split(filepath.ToSlash(relativePath), "/") {
if directory == "testdata" {
return true
}
}

return false
}

func extractRoot(folderList messaging.Folders, packageList []*contract.Package) string {
path := packageList[0].Path
folder := folderList[path]
Expand Down

0 comments on commit 0fc5ef5

Please sign in to comment.