Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from shubham-cmyk/fix-runs
Browse files Browse the repository at this point in the history
[Fix] : Test executed while marked skipped
  • Loading branch information
eddycharly authored Sep 12, 2023
2 parents 3561869 + b463f9d commit 2eb6c61
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,15 @@ func (h *Harness) RunTests() {
}
}
}

failureOccurred := false

var failureOccurred = false
h.T.Run("harness", func(t *testing.T) {
for testDir, tests := range realTestSuite {
h.T.Logf("testsuite: %s has %d tests", testDir, len(tests))
suite := h.report.NewSuite(testDir)
if failureOccurred && h.TestSuite.StopOnFirstFailure {
t.SkipNow()
break
}
for _, test := range tests {
test := test

Expand All @@ -420,7 +422,10 @@ func (h *Harness) RunTests() {
if h.TestSuite.FullName {
name = path.Join(strings.Trim(strings.Trim(testDir, "."), "/"), name)
}

if failureOccurred && h.TestSuite.StopOnFirstFailure {
t.SkipNow()
break
}
t.Run(name, func(t *testing.T) {
// testing.T.Parallel may block, so run it before we read time for our
// elapsed time calculations.
Expand All @@ -429,24 +434,18 @@ func (h *Harness) RunTests() {
test.Logger = testutils.NewTestLogger(t, name)

tc := report.NewCase(name)
// Check before every test case if a failure has occurred
if failureOccurred && h.TestSuite.StopOnFirstFailure {
t.SkipNow()
return
}
test.Run(t, tc)
if tc.Failure != nil {
// assuming tc.Failure is set when a test case fails
failureOccurred = true
}
suite.AddTestcase(tc)
// Check after every test case if a failure has occurred
if failureOccurred && h.TestSuite.StopOnFirstFailure {
t.SkipNow()
return
}
})
if failureOccurred && h.TestSuite.StopOnFirstFailure {
break
}
}
if failureOccurred && h.TestSuite.StopOnFirstFailure {
break
}
}
})
Expand Down

0 comments on commit 2eb6c61

Please sign in to comment.