runScripts is the implementation of both RunScripts and RunScriptsWithoutNormalization.
(t *testing.T, scripts []ScriptTest, normalizeRows bool)
| 362 | |
| 363 | // runScripts is the implementation of both RunScripts and RunScriptsWithoutNormalization. |
| 364 | func runScripts(t *testing.T, scripts []ScriptTest, normalizeRows bool) { |
| 365 | // First, we'll run through the scripts to check for the Focus variable. If it's true, then append it to the new slice. |
| 366 | focusScripts := make([]ScriptTest, 0, len(scripts)) |
| 367 | for _, script := range scripts { |
| 368 | if script.Focus { |
| 369 | // If this is running in GitHub Actions, then we'll panic, because someone forgot to disable it before committing |
| 370 | if _, ok := os.LookupEnv("GITHUB_ACTION"); ok { |
| 371 | panic(fmt.Sprintf("The script `%s` has Focus set to `true`. GitHub Actions requires that "+ |
| 372 | "all tests are run, which Focus circumvents, leading to this error. Please disable Focus on "+ |
| 373 | "all tests.", script.Name)) |
| 374 | } |
| 375 | focusScripts = append(focusScripts, script) |
| 376 | } |
| 377 | } |
| 378 | // If we have scripts with Focus set, then we replace the normal script slice with the new slice. |
| 379 | if len(focusScripts) > 0 { |
| 380 | scripts = focusScripts |
| 381 | } |
| 382 | |
| 383 | for _, script := range scripts { |
| 384 | RunScript(t, script, normalizeRows) |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | func ptr[T any](val T) *T { |
| 389 | return &val |
no test coverage detected