Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop compiling and testing packages in testdata #488

Merged
merged 1 commit into from Apr 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions goconvey.go
Expand Up @@ -128,12 +128,37 @@ 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)
packageList = append(packageList, contract.NewPackage(folder, hasImportCycle))
}
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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment to this function explaining the situation?

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