From 5b19f2cc8788c6352ca34514570f2ea2fd8cf9e7 Mon Sep 17 00:00:00 2001 From: Ondřej Budai Date: Nov 29 2019 08:32:09 +0000 Subject: Fix not listing packages with external tests only Prior this commit golist with --tests didn't list packages which had only external tests. E.g. it didn't list package foo if it only had tests in package foo_test (and not in foo package). This commit fixes this behaviour. --- diff --git a/pkg/util/util.go b/pkg/util/util.go index 4812399..c3da934 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -344,14 +344,14 @@ func (p *PackageInfoCollector) BuildPackageTree(includeMain, withTests, testsOnl var entryPoints []string if testsOnly { for p, pkgInfo := range p.packageInfos { - if len(pkgInfo.TestGoFiles) > 0 { + if len(pkgInfo.TestGoFiles) > 0 || len(pkgInfo.XTestGoFiles) > 0 { entryPoints = append(entryPoints, p) } } } else { if withTests { for p, pkgInfo := range p.packageInfos { - if len(pkgInfo.TestGoFiles) > 0 { + if len(pkgInfo.TestGoFiles) > 0 || len(pkgInfo.XTestGoFiles) > 0 { entryPoints = append(entryPoints, p) } }