diff --git a/rules/rules_test.go b/rules/rules_test.go index 2acb68a..f1c80b7 100644 --- a/rules/rules_test.go +++ b/rules/rules_test.go @@ -39,6 +39,7 @@ var _ = Describe("gosec rules", func() { } err := pkg.Build() Expect(err).ShouldNot(HaveOccurred()) + Expect(pkg.PrintErrors()).Should(BeZero()) err = analyzer.Process(buildTags, pkg.Path) Expect(err).ShouldNot(HaveOccurred()) issues, _, _ := analyzer.Report() diff --git a/testutils/pkg.go b/testutils/pkg.go index 687ce6c..eb9cd42 100644 --- a/testutils/pkg.go +++ b/testutils/pkg.go @@ -142,3 +142,8 @@ func (p *TestPackage) Pkgs() []*packages.Package { } return []*packages.Package{} } + +// PrintErrors prints to os.Stderr the accumulated errors of built packages +func (p *TestPackage) PrintErrors() int { + return packages.PrintErrors(p.Pkgs()) +}