MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestPermanentFailure

Function TestPermanentFailure

cmd/testwrapper/testwrapper_test.go:171–209  ·  view source on GitHub ↗

TestPermanentFailure covers a test that always fails: the wrapper must exit non-zero, emit a permanent test failures JSON line, and NOT emit a flakytest failures JSON line. The test should be retried at least minRetries times.

(t *testing.T)

Source from the content-addressed store, hash-verified

169// non-zero, emit a permanent test failures JSON line, and NOT emit a flakytest
170// failures JSON line. The test should be retried at least minRetries times.
171func TestPermanentFailure(t *testing.T) {
172 t.Parallel()
173
174 testfile := filepath.Join(t.TempDir(), "permfail_test.go")
175 code := []byte(`package permfail_test
176
177import "testing"
178
179func TestAlwaysFail(t *testing.T) {
180 t.Fatal("always fails")
181}
182`)
183 if err := os.WriteFile(testfile, code, 0o644); err != nil {
184 t.Fatalf("writing package: %s", err)
185 }
186
187 out, err := cmdTestwrapper(t, "-v", testfile).CombinedOutput()
188 if err == nil {
189 t.Fatalf("testwrapper %s: expected error but it succeeded with output:\n%s", testfile, out)
190 }
191 if code, ok := errExitCode(err); ok && code != 1 {
192 t.Errorf("expected exit code 1 but got %d; output:\n%s", code, out)
193 }
194
195 if bytes.Contains(out, []byte("flakytest failures JSON:")) {
196 t.Errorf("unexpected flakytest failures JSON line in output (test never passed):\n%s", out)
197 }
198 if !bytes.Contains(out, []byte("permanent test failures JSON:")) {
199 t.Errorf("missing permanent test failures JSON line in output:\n%s", out)
200 }
201 // First pass + at least minRetries retries = 3 runs.
202 if runs := bytes.Count(out, []byte("=== RUN TestAlwaysFail")); runs < 3 {
203 t.Errorf("expected TestAlwaysFail to run >= 3 times (1 first + 2 retries) but ran %d times in output:\n%s", runs, out)
204 }
205
206 if testing.Verbose() {
207 t.Logf("success - output:\n%s", out)
208 }
209}
210
211// TestRaceSuppressesFlakyRetry verifies that detecting a data race
212// in a package's output stops testwrapper from retrying any flaky

Callers

nothing calls this directly

Calls 9

cmdTestwrapperFunction · 0.85
errExitCodeFunction · 0.85
CombinedOutputMethod · 0.80
TempDirMethod · 0.65
WriteFileMethod · 0.65
FatalfMethod · 0.65
ErrorfMethod · 0.65
LogfMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…