1
0
mirror of https://github.com/mgechev/revive.git synced 2025-07-07 00:35:38 +02:00
This commit is contained in:
mgechev
2017-11-26 19:06:02 -08:00
parent 419da3b95d
commit 1858f4f7c2
4 changed files with 123 additions and 3 deletions

View File

@ -53,14 +53,14 @@ func stripAnnotations(code string) string {
}
// AssertSuccess checks if given rule runs correctly with no failures.
func AssertSuccess(t *testing.T, code string, testingRule rule.Rule, args rule.Arguments) {
func AssertSuccessWithName(t *testing.T, code, name string, testingRule rule.Rule, args rule.Arguments) {
annotations := extractFailures(code)
if annotations != nil {
t.Errorf("There should be no failure annotations when verifying successful rule analysis")
}
var fileSet token.FileSet
file, err := file.New("testing.go", []byte(stripAnnotations(code)), &fileSet)
file, err := file.New(name, []byte(stripAnnotations(code)), &fileSet)
if err != nil {
t.Errorf("Cannot parse testing file: %s", err.Error())
}
@ -78,6 +78,11 @@ func AssertSuccess(t *testing.T, code string, testingRule rule.Rule, args rule.A
}
}
// AssertSuccess checks if given rule runs correctly with no failures.
func AssertSuccess(t *testing.T, code string, testingRule rule.Rule, args rule.Arguments) {
AssertSuccessWithName(t, code, "testing.go", testingRule, args)
}
// AssertFailures checks if given rule runs correctly with failures.
func AssertFailures(t *testing.T, code string, testingRule rule.Rule, args rule.Arguments) {
annotations := extractFailures(code)