-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
failint: add ability to lint only tests
Add the ability to lint only testing functions. This is useful to prevent hardcoded sleeps in tests leading to flaky tests. I have never worked with the AST package in Go so this requires extra carefulness. Signed-off-by: Giedrius Statkevičius <[email protected]>
- Loading branch information
Showing
4 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package sleepintest | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
func fooTest() { | ||
time.Sleep(1 * time.Second) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package sleepintest | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestFoo(t *testing.T) { | ||
time.Sleep(1 * time.Second) // want `declaration "Sleep" from package "time" shouldn't be used` | ||
} |