Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Verify executed tests taking include/exclude option into account #320

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions runner/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ func (s *runTestSuite) TestRunTests_Run() {
ShowTime: true,
}, s.out)
s.Require().NoError(err)
s.Len(res.Stats.Success, 5, "verbose and execute all failed")
s.Len(res.Stats.Skipped, 0, "verbose and execute all failed")
s.Equal(res.Stats.TotalFailed(), 0, "verbose and execute all failed")
})

Expand All @@ -285,33 +287,41 @@ func (s *runTestSuite) TestRunTests_Run() {
Include: regexp.MustCompile("0*"),
}, s.out)
s.Require().NoError(err)
s.Len(res.Stats.Success, 5, "do not show time and execute all failed")
s.Len(res.Stats.Skipped, 0, "do not show time and execute all failed")
s.Equal(res.Stats.TotalFailed(), 0, "do not show time and execute all failed")
})

s.Run("execute only test 008 but exclude all", func() {
s.Run("execute only test 8 but exclude all", func() {
res, err := Run(s.cfg, s.ftwTests, RunnerConfig{
Include: regexp.MustCompile("008"),
Include: regexp.MustCompile("-8$"), // test ID is matched in format `<ruleId>-<testId>`
Exclude: regexp.MustCompile("0*"),
}, s.out)
s.Require().NoError(err)
s.Equal(res.Stats.TotalFailed(), 0, "do not show time and execute all failed")
s.Len(res.Stats.Success, 1, "execute only test 008 but exclude all")
s.Len(res.Stats.Skipped, 4, "execute only test 008 but exclude all")
s.Equal(res.Stats.TotalFailed(), 0, "execute only test 008 but exclude all")
})

s.Run("exclude test 010", func() {
s.Run("exclude test 10", func() {
res, err := Run(s.cfg, s.ftwTests, RunnerConfig{
Exclude: regexp.MustCompile("010"),
Exclude: regexp.MustCompile("-10$"), // test ID is matched in format `<ruleId>-<testId>`
}, s.out)
s.Require().NoError(err)
s.Len(res.Stats.Success, 4, "failed to exclude test")
s.Len(res.Stats.Skipped, 1, "failed to exclude test")
s.Equal(res.Stats.TotalFailed(), 0, "failed to exclude test")
})

s.Run("test exceptions 1", func() {
res, err := Run(s.cfg, s.ftwTests, RunnerConfig{
Include: regexp.MustCompile("1*"),
Exclude: regexp.MustCompile("0*"),
Include: regexp.MustCompile("-1.*"),
Exclude: regexp.MustCompile("-0.*"),
Output: output.Quiet,
}, s.out)
s.Require().NoError(err)
s.Len(res.Stats.Success, 4, "failed to test exceptions")
s.Len(res.Stats.Skipped, 1, "failed to test exceptions")
s.Equal(res.Stats.TotalFailed(), 0, "failed to test exceptions")
})
}
Expand Down