(t *testing.T)
| 321 | } |
| 322 | |
| 323 | func TestBuildError(t *testing.T) { |
| 324 | t.Parallel() |
| 325 | |
| 326 | // Construct our broken package. |
| 327 | testfile := filepath.Join(t.TempDir(), "builderror_test.go") |
| 328 | code := []byte("package builderror_test\n\nderp") |
| 329 | err := os.WriteFile(testfile, code, 0o644) |
| 330 | if err != nil { |
| 331 | t.Fatalf("writing package: %s", err) |
| 332 | } |
| 333 | |
| 334 | wantErr := "builderror_test.go:3:1: expected declaration, found derp\nFAIL" |
| 335 | |
| 336 | // Confirm `go test` exits with code 1. |
| 337 | goOut, err := exec.Command("go", "test", testfile).CombinedOutput() |
| 338 | if code, ok := errExitCode(err); !ok || code != 1 { |
| 339 | t.Fatalf("go test %s: got exit code %d, want 1 (err: %v)", testfile, code, err) |
| 340 | } |
| 341 | if !strings.Contains(string(goOut), wantErr) { |
| 342 | t.Fatalf("go test %s: got output %q, want output containing %q", testfile, goOut, wantErr) |
| 343 | } |
| 344 | |
| 345 | // Confirm `testwrapper` exits with code 1. |
| 346 | twOut, err := cmdTestwrapper(t, testfile).CombinedOutput() |
| 347 | if code, ok := errExitCode(err); !ok || code != 1 { |
| 348 | t.Fatalf("testwrapper %s: got exit code %d, want 1 (err: %v)", testfile, code, err) |
| 349 | } |
| 350 | if !strings.Contains(string(twOut), wantErr) { |
| 351 | t.Fatalf("testwrapper %s: got output %q, want output containing %q", testfile, twOut, wantErr) |
| 352 | } |
| 353 | |
| 354 | if testing.Verbose() { |
| 355 | t.Logf("success - output:\n%s", twOut) |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | func TestTimeout(t *testing.T) { |
| 360 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…