-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skip.go
59 lines (51 loc) · 1.44 KB
/
skip.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package ci
import "testing"
func skipIf[T Testing](f func() bool, t T) {
if f() {
t.SkipNow()
}
}
// SkipTestIfCI is a testing helper function that skips the execution of a test
// if it is running within a CI/CD pipeline.
//
// Example:
//
// func TestYourFunc(t *testing.T) {
// defer func() {
// println(t.Skipped())
// // Output: true
// }()
//
// t.Setenv("CI", "true")
// ci.SkipTestIfCI(t)
//
// // do your test...
// }
func SkipTestIfCI(t *testing.T) {
skipIf(IsCI, t)
}
// SkipTestIfNotCI is a testing helper function that skips the execution of a
// test if it is not running within a CI/CD pipeline.
func SkipTestIfNotCI(t *testing.T) {
skipIf(IsNotCI, t)
}
// SkipBenchmarkIfCI is a testing helper function that skips the execution of a
// benchmark if it is running within a CI/CD pipeline.
func SkipBenchmarkIfCI(b *testing.B) {
skipIf(IsCI, b)
}
// SkipBenchmarkIfNotCI is a testing helper function that skips the execution of
// a benchmark if it is not running within a CI/CD pipeline.
func SkipBenchmarkIfNotCI(b *testing.B) {
skipIf(IsNotCI, b)
}
// SkipFuzzIfCI is a testing helper function that skips the execution of a fuzz
// test if it is running within a CI/CD pipeline.
func SkipFuzzIfCI(f *testing.F) {
skipIf(IsCI, f)
}
// SkipFuzzIfNotCI is a testing helper function that skips the execution of a
// fuzz test if it is not running within a CI/CD pipeline.
func SkipFuzzIfNotCI(f *testing.F) {
skipIf(IsNotCI, f)
}