testing/e2e: add option to skip slow test (#4380)

pull/4381/head
Johan Brandhorst-Satzkorn 2 years ago committed by GitHub
parent 69512baa8b
commit be252e3447
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -7,7 +7,6 @@ import (
"bytes"
"context"
"errors"
"fmt"
"os"
"os/exec"
"testing"
@ -48,7 +47,10 @@ func getOpts(opt ...Option) options {
return opts
}
const EnvToCheckSkip = "E2E_TESTS"
const (
EnvToCheckSkip = "E2E_TESTS"
EnvToCheckSlowSkip = "E2E_SLOW_TESTS"
)
// RunCommand executes external commands on the system. Returns the results
// of running the provided command.
@ -130,9 +132,20 @@ func WithEnv(name string, value string) Option {
// MaybeSkipTest is a check used at the start of the test to determine if the test should run
func MaybeSkipTest(t testing.TB) {
if _, ok := os.LookupEnv(EnvToCheckSkip); !ok {
t.Skip(fmt.Sprintf(
t.Skipf(
"Skipping test because environment variable '%s' is not set. This is needed for e2e tests.",
EnvToCheckSkip,
))
)
}
}
// MaybeSkipSlowTest is a check used at the start of the test to determine if the test should run
func MaybeSkipSlowTest(t testing.TB) {
MaybeSkipTest(t)
if _, ok := os.LookupEnv(EnvToCheckSlowSkip); !ok {
t.Skipf(
"Skipping test because environment variable '%s' is not set. This is needed for slow e2e tests.",
EnvToCheckSlowSkip,
)
}
}

Loading…
Cancel
Save