mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Assert that sample code compiles
This commit is contained in:
parent
bcfb27955e
commit
e100f6b862
2 changed files with 6 additions and 0 deletions
|
@ -39,6 +39,7 @@ var _ = Describe("gosec rules", func() {
|
||||||
}
|
}
|
||||||
err := pkg.Build()
|
err := pkg.Build()
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
Expect(pkg.PrintErrors()).Should(BeZero())
|
||||||
err = analyzer.Process(buildTags, pkg.Path)
|
err = analyzer.Process(buildTags, pkg.Path)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
issues, _, _ := analyzer.Report()
|
issues, _, _ := analyzer.Report()
|
||||||
|
|
|
@ -142,3 +142,8 @@ func (p *TestPackage) Pkgs() []*packages.Package {
|
||||||
}
|
}
|
||||||
return []*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())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue