Skip to content

Commit e100f6b

Browse files
cbandyCosmin Cojocar
authored andcommitted
Assert that sample code compiles
1 parent bcfb279 commit e100f6b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

rules/rules_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var _ = Describe("gosec rules", func() {
3939
}
4040
err := pkg.Build()
4141
Expect(err).ShouldNot(HaveOccurred())
42+
Expect(pkg.PrintErrors()).Should(BeZero())
4243
err = analyzer.Process(buildTags, pkg.Path)
4344
Expect(err).ShouldNot(HaveOccurred())
4445
issues, _, _ := analyzer.Report()

testutils/pkg.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,8 @@ func (p *TestPackage) Pkgs() []*packages.Package {
142142
}
143143
return []*packages.Package{}
144144
}
145+
146+
// PrintErrors prints to os.Stderr the accumulated errors of built packages
147+
func (p *TestPackage) PrintErrors() int {
148+
return packages.PrintErrors(p.Pkgs())
149+
}

0 commit comments

Comments
 (0)