Skip to content

Commit 16cbe0d

Browse files
committed
Fix skipped tests
1 parent bcc79cf commit 16cbe0d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tools/flakeguard/runner/runner.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
407407
// Clear temporary outputs
408408
delete(result.Outputs, runID)
409409
}
410+
case "skip":
411+
if entryLine.Test != "" {
412+
result.Skipped = true
413+
result.Skips++
414+
}
410415
case "output":
411416
// Handled above when entryLine.Test is not empty
412417
}

tools/flakeguard/runner/runner_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,39 @@ func TestFailedOutputs(t *testing.T) {
531531
}
532532
}
533533

534+
func TestSkippedTests(t *testing.T) {
535+
t.Parallel()
536+
537+
runner := Runner{
538+
ProjectPath: "./",
539+
Verbose: true,
540+
RunCount: 1,
541+
SelectedTestPackages: []string{flakyTestPackagePath},
542+
SelectTests: []string{"TestSkipped"}, // Known skipping test
543+
CollectRawOutput: true,
544+
}
545+
546+
testReport, err := runner.RunTests()
547+
require.NoError(t, err, "running tests should not produce an unexpected error")
548+
549+
require.Equal(t, 1, testReport.TestRunCount, "unexpected number of test runs")
550+
551+
var testSkipResult *reports.TestResult
552+
for i := range testReport.Results {
553+
if testReport.Results[i].TestName == "TestSkipped" {
554+
testSkipResult = &testReport.Results[i]
555+
break
556+
}
557+
}
558+
require.NotNil(t, testSkipResult, "expected 'TestSkipped' result not found in report")
559+
560+
// Check that the test was properly marked as skipped
561+
require.True(t, testSkipResult.Skipped, "test 'TestSkipped' should be marked as skipped")
562+
require.Equal(t, 0, testSkipResult.Failures, "test 'TestSkipped' should have no failures")
563+
require.Equal(t, 0, testSkipResult.Successes, "test 'TestSkipped' should have no successes")
564+
require.Equal(t, 1, testSkipResult.Skips, "test 'TestSkipped' should have exactly one skip recorded")
565+
}
566+
534567
func TestOmitOutputsOnSuccess(t *testing.T) {
535568
t.Parallel()
536569

0 commit comments

Comments
 (0)