fix: failing tests to not count as an error

This commit is contained in:
2026-03-21 07:45:09 +00:00
parent 88ad09fa6d
commit ee9ae6b127
2 changed files with 10 additions and 22 deletions
+10 -10
View File
@@ -328,7 +328,7 @@ func TestRunTestScopedLeafDirectory(t *testing.T) {
})
}
func TestRunTestReturnsOneWhenScenarioMismatches(t *testing.T) {
func TestRunTestReturnsZeroWhenScenarioMismatches(t *testing.T) {
addFakeRecordDependencies(t, "script", "bwrap", "bash")
t.Setenv("FAKE_SCRIPT_ECHO_STDIN", "1")
@@ -350,8 +350,8 @@ func TestRunTestReturnsOneWhenScenarioMismatches(t *testing.T) {
}
stdout, stderr := captureOutput(t, func() {
if got := Run([]string{"test"}); got != 1 {
t.Fatalf("Run() code = %d, want %d", got, 1)
if got := Run([]string{"test"}); got != 0 {
t.Fatalf("Run() code = %d, want %d", got, 0)
}
})
@@ -366,8 +366,8 @@ func TestRunTestReturnsOneWhenScenarioMismatches(t *testing.T) {
t.Fatalf("stdout = %q, want substring %q", stdout, want)
}
}
if !strings.Contains(stderr, "1 scenario(s) failed") {
t.Fatalf("stderr = %q, want suite failure", stderr)
if stderr != "" {
t.Fatalf("stderr = %q, want empty", stderr)
}
})
}
@@ -439,7 +439,7 @@ func TestRunTestFailsWhenFixtureMalformed(t *testing.T) {
})
}
func TestRunTestFailsWhenCompareMarkerMissing(t *testing.T) {
func TestRunTestReturnsZeroWhenCompareMarkerMissing(t *testing.T) {
addFakeRecordDependencies(t, "script", "bwrap", "bash")
t.Setenv("FAKE_SCRIPT_ECHO_STDIN", "1")
@@ -450,8 +450,8 @@ func TestRunTestFailsWhenCompareMarkerMissing(t *testing.T) {
withWorkingDir(t, root, func() {
stdout, stderr := captureOutput(t, func() {
if got := Run([]string{"test"}); got != 1 {
t.Fatalf("Run() code = %d, want %d", got, 1)
if got := Run([]string{"test"}); got != 0 {
t.Fatalf("Run() code = %d, want %d", got, 0)
}
})
@@ -464,8 +464,8 @@ func TestRunTestFailsWhenCompareMarkerMissing(t *testing.T) {
t.Fatalf("stdout = %q, want substring %q", stdout, want)
}
}
if !strings.Contains(stderr, "1 scenario(s) failed") {
t.Fatalf("stderr = %q, want suite failure", stderr)
if stderr != "" {
t.Fatalf("stderr = %q, want empty", stderr)
}
})
}
-12
View File
@@ -36,14 +36,6 @@ type testFixtureFiles struct {
outPath string
}
type TestSuiteFailedError struct {
Failed int
}
func (e TestSuiteFailedError) Error() string {
return fmt.Sprintf("%d scenario(s) failed", e.Failed)
}
// RunTests replays all scenarios under the configured test directory.
func RunTests(path string) error {
return runTests(path, testIO{
@@ -114,10 +106,6 @@ func runTests(path string, tio testIO) error {
),
)
if summary.failed > 0 {
return TestSuiteFailedError{Failed: summary.failed}
}
return nil
}