Skip to content

Commit

Permalink
Fix checking testing outputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
tetafro committed Sep 9, 2024
1 parent e058429 commit f031750
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ func isSpecialBlock(comment string) bool {
strings.Contains(comment, "#define")) {
return true
}
// This should only be skipped in test files, but we don't have this
// information here, so - always skip
if strings.HasPrefix(comment, "// Output:") ||
strings.HasPrefix(comment, "// Unordered output:") {
return true
Expand Down
6 changes: 1 addition & 5 deletions getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,8 @@ func (pf *parsedFile) getAllComments(exclude []*regexp.Regexp) []comment {
// special lines (e.g., tags or indented code examples), they are replaced
// with `specialReplacer` to skip checks for them.
// The result can be multiline.
//
//nolint:cyclop
func getText(comment *ast.CommentGroup, exclude []*regexp.Regexp) (s string) {
if len(comment.List) == 1 &&
strings.HasPrefix(comment.List[0].Text, "/*") &&
isSpecialBlock(comment.List[0].Text) {
if len(comment.List) > 0 && isSpecialBlock(comment.List[0].Text) {
return ""
}

Expand Down
7 changes: 7 additions & 0 deletions testdata/check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ func nonCapital() int {
return x // non-capital-all [CAPITAL_ALL].
}

// ExamplePrintln is a function that you would normally see in tests.
func ExamplePrintln() {
fmt.Println("hello")
// Output:
// hello [PASS]
}

// Comment with a URL - http://example.com/[PASS]

// Multiline comment with a URL
Expand Down

0 comments on commit f031750

Please sign in to comment.