github.com/hashicorp/nomad/api@v0.0.0-20240306165712-3193ac204f65/internal/testutil/slow.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package testutil 5 6 import ( 7 "os" 8 "strconv" 9 "syscall" 10 "testing" 11 ) 12 13 // Copy of ci/slow.go for API. 14 15 // SkipSlow skips a slow test unless NOMAD_SLOW_TEST is set to a true value. 16 func SkipSlow(t *testing.T, reason string) { 17 value := os.Getenv("NOMAD_SLOW_TEST") 18 run, err := strconv.ParseBool(value) 19 if !run || err != nil { 20 t.Skipf("Skipping slow test: %s", reason) 21 } 22 } 23 24 // Parallel runs t in parallel. 25 // 26 // The API package has been vetted to be concurrency safe (ish). 27 func Parallel(t *testing.T) { 28 t.Parallel() // :) 29 } 30 31 func RequireRoot(t *testing.T) { 32 t.Helper() 33 if syscall.Getuid() != 0 { 34 t.Skip("test requires root") 35 } 36 }