(t *testing.T)
| 357 | } |
| 358 | |
| 359 | func TestTimeout(t *testing.T) { |
| 360 | t.Parallel() |
| 361 | |
| 362 | // Construct our broken package. |
| 363 | testfile := filepath.Join(t.TempDir(), "timeout_test.go") |
| 364 | code := []byte(`package noretry_test |
| 365 | |
| 366 | import ( |
| 367 | "testing" |
| 368 | "time" |
| 369 | ) |
| 370 | |
| 371 | func TestTimeout(t *testing.T) { |
| 372 | time.Sleep(500 * time.Millisecond) |
| 373 | } |
| 374 | `) |
| 375 | err := os.WriteFile(testfile, code, 0o644) |
| 376 | if err != nil { |
| 377 | t.Fatalf("writing package: %s", err) |
| 378 | } |
| 379 | |
| 380 | out, err := cmdTestwrapper(t, testfile, "-timeout=20ms").CombinedOutput() |
| 381 | if code, ok := errExitCode(err); !ok || code != 1 { |
| 382 | t.Fatalf("testwrapper %s: expected error with exit code 1 but got: %v; output was:\n%s", testfile, err, out) |
| 383 | } |
| 384 | if want := "panic: test timed out after 20ms"; !bytes.Contains(out, []byte(want)) { |
| 385 | t.Fatalf("testwrapper %s: expected timeout panic containing %q but got:\n%s", testfile, want, out) |
| 386 | } |
| 387 | |
| 388 | if testing.Verbose() { |
| 389 | t.Logf("success - output:\n%s", out) |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | func TestCached(t *testing.T) { |
| 394 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…