go/analysis/analysistest: refuse to analyze zero packages
It's easy to forget to pass the last argument, in which case the test would silently pass. Change-Id: I95249e1fe8bee75cfaa535fcf723d04f102214fc Reviewed-on: https://go-review.googlesource.com/138395 Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
ae8529dc16
commit
7b71b077e1
|
@ -66,6 +66,9 @@ type Testing interface {
|
||||||
// You may wish to call this function from within a (*testing.T).Run
|
// You may wish to call this function from within a (*testing.T).Run
|
||||||
// subtest to ensure that errors have adequate contextual description.
|
// subtest to ensure that errors have adequate contextual description.
|
||||||
func Run(t Testing, dir string, a *analysis.Analyzer, pkgnames ...string) {
|
func Run(t Testing, dir string, a *analysis.Analyzer, pkgnames ...string) {
|
||||||
|
if pkgnames == nil {
|
||||||
|
t.Errorf("Run: no packages")
|
||||||
|
}
|
||||||
for _, pkgname := range pkgnames {
|
for _, pkgname := range pkgnames {
|
||||||
pkg, err := loadPackage(dir, pkgname)
|
pkg, err := loadPackage(dir, pkgname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue