(t *testing.T, fn func())
| 208 | } |
| 209 | |
| 210 | func captureStdout(t *testing.T, fn func()) string { |
| 211 | t.Helper() |
| 212 | r, w, err := os.Pipe() |
| 213 | if err != nil { |
| 214 | t.Fatalf("failed to create pipe: %v", err) |
| 215 | } |
| 216 | old := os.Stdout |
| 217 | os.Stdout = w |
| 218 | |
| 219 | fn() |
| 220 | |
| 221 | w.Close() |
| 222 | os.Stdout = old |
| 223 | |
| 224 | data, err2 := io.ReadAll(r) |
| 225 | if err2 != nil { |
| 226 | t.Fatalf("failed to read pipe: %v", err2) |
| 227 | } |
| 228 | return string(data) |
| 229 | } |
| 230 | |
| 231 | func TestPrintBanner_Default(t *testing.T) { |
| 232 | dir := createTestTaskDir(t) |
no test coverage detected