2022-03-15 12:42:43 +00:00
|
|
|
package ci
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SkipSlow skips a slow test unless NOMAD_SLOW_TEST is set to a true value.
|
|
|
|
func SkipSlow(t *testing.T, reason string) {
|
|
|
|
value := os.Getenv("NOMAD_SLOW_TEST")
|
|
|
|
run, err := strconv.ParseBool(value)
|
|
|
|
if !run || err != nil {
|
|
|
|
t.Skipf("Skipping slow test: %s", reason)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parallel runs t in parallel, unless CI is set to a true value.
|
2022-03-16 13:38:42 +00:00
|
|
|
//
|
|
|
|
// In CI (CircleCI / GitHub Actions) we get better performance by running tests
|
|
|
|
// in serial while not restricting GOMAXPROCS.
|
2022-03-15 12:42:43 +00:00
|
|
|
func Parallel(t *testing.T) {
|
|
|
|
value := os.Getenv("CI")
|
|
|
|
isCI, err := strconv.ParseBool(value)
|
|
|
|
if !isCI || err != nil {
|
|
|
|
t.Parallel()
|
|
|
|
}
|
|
|
|
}
|