fix: failing tests to not count as an error
This commit is contained in:
+10
-10
@@ -328,7 +328,7 @@ func TestRunTestScopedLeafDirectory(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunTestReturnsOneWhenScenarioMismatches(t *testing.T) {
|
func TestRunTestReturnsZeroWhenScenarioMismatches(t *testing.T) {
|
||||||
addFakeRecordDependencies(t, "script", "bwrap", "bash")
|
addFakeRecordDependencies(t, "script", "bwrap", "bash")
|
||||||
t.Setenv("FAKE_SCRIPT_ECHO_STDIN", "1")
|
t.Setenv("FAKE_SCRIPT_ECHO_STDIN", "1")
|
||||||
|
|
||||||
@@ -350,8 +350,8 @@ func TestRunTestReturnsOneWhenScenarioMismatches(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stdout, stderr := captureOutput(t, func() {
|
stdout, stderr := captureOutput(t, func() {
|
||||||
if got := Run([]string{"test"}); got != 1 {
|
if got := Run([]string{"test"}); got != 0 {
|
||||||
t.Fatalf("Run() code = %d, want %d", got, 1)
|
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)
|
t.Fatalf("stdout = %q, want substring %q", stdout, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !strings.Contains(stderr, "1 scenario(s) failed") {
|
if stderr != "" {
|
||||||
t.Fatalf("stderr = %q, want suite failure", 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")
|
addFakeRecordDependencies(t, "script", "bwrap", "bash")
|
||||||
t.Setenv("FAKE_SCRIPT_ECHO_STDIN", "1")
|
t.Setenv("FAKE_SCRIPT_ECHO_STDIN", "1")
|
||||||
|
|
||||||
@@ -450,8 +450,8 @@ func TestRunTestFailsWhenCompareMarkerMissing(t *testing.T) {
|
|||||||
|
|
||||||
withWorkingDir(t, root, func() {
|
withWorkingDir(t, root, func() {
|
||||||
stdout, stderr := captureOutput(t, func() {
|
stdout, stderr := captureOutput(t, func() {
|
||||||
if got := Run([]string{"test"}); got != 1 {
|
if got := Run([]string{"test"}); got != 0 {
|
||||||
t.Fatalf("Run() code = %d, want %d", got, 1)
|
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)
|
t.Fatalf("stdout = %q, want substring %q", stdout, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !strings.Contains(stderr, "1 scenario(s) failed") {
|
if stderr != "" {
|
||||||
t.Fatalf("stderr = %q, want suite failure", stderr)
|
t.Fatalf("stderr = %q, want empty", stderr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ type testFixtureFiles struct {
|
|||||||
outPath string
|
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.
|
// RunTests replays all scenarios under the configured test directory.
|
||||||
func RunTests(path string) error {
|
func RunTests(path string) error {
|
||||||
return runTests(path, testIO{
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user