-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfail.go
45 lines (37 loc) · 1.23 KB
/
fail.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package ci
import "testing"
func failIf[T Testing](f func() bool, t T) {
if f() {
t.FailNow()
}
}
// FailTestIfCI is a testing helper function that fails the execution of a test
// if it is running within a CI/CD pipeline.
func FailTestIfCI(t *testing.T) {
failIf(IsCI, t)
}
// FailTestIfNotCI is a testing helper function that fails the execution of a
// test if it is not running within a CI/CD pipeline.
func FailTestIfNotCI(t *testing.T) {
failIf(IsNotCI, t)
}
// FailBenchmarkIfCI is a testing helper function that fails the execution of a
// benchmark if it is running within a CI/CD pipeline.
func FailBenchmarkIfCI(b *testing.B) {
failIf(IsCI, b)
}
// FailBenchmarkIfNotCI is a testing helper function that fails the execution of
// a benchmark if it is not running within a CI/CD pipeline.
func FailBenchmarkIfNotCI(b *testing.B) {
failIf(IsNotCI, b)
}
// FailFuzzIfCI is a testing helper function that fails the execution of a fuzz
// test if it is running within a CI/CD pipeline.
func FailFuzzIfCI(f *testing.F) {
failIf(IsCI, f)
}
// FailFuzzIfNotCI is a testing helper function that fails the execution of a
// fuzz test if it is not running within a CI/CD pipeline.
func FailFuzzIfNotCI(f *testing.F) {
failIf(IsNotCI, f)
}