5
5
"time"
6
6
7
7
. "github.com/onsi/ginkgo/v2"
8
+ "github.com/onsi/ginkgo/v2/types"
8
9
. "github.com/onsi/gomega"
9
10
"github.com/onsi/gomega/gleak"
10
11
@@ -19,19 +20,19 @@ var _ = Describe("ProgressReporterManager", func() {
19
20
})
20
21
21
22
It ("can attach and detach progress reporters" , func () {
22
- Ω (manager .QueryProgressReporters (context .Background ())).Should (BeEmpty ())
23
+ Ω (manager .QueryProgressReporters (context .Background (), nil )).Should (BeEmpty ())
23
24
cancelA := manager .AttachProgressReporter (func () string { return "A" })
24
- Ω (manager .QueryProgressReporters (context .Background ())).Should (Equal ([]string {"A" }))
25
+ Ω (manager .QueryProgressReporters (context .Background (), nil )).Should (Equal ([]string {"A" }))
25
26
cancelB := manager .AttachProgressReporter (func () string { return "B" })
26
- Ω (manager .QueryProgressReporters (context .Background ())).Should (Equal ([]string {"A" , "B" }))
27
+ Ω (manager .QueryProgressReporters (context .Background (), nil )).Should (Equal ([]string {"A" , "B" }))
27
28
cancelC := manager .AttachProgressReporter (func () string { return "C" })
28
- Ω (manager .QueryProgressReporters (context .Background ())).Should (Equal ([]string {"A" , "B" , "C" }))
29
+ Ω (manager .QueryProgressReporters (context .Background (), nil )).Should (Equal ([]string {"A" , "B" , "C" }))
29
30
cancelB ()
30
- Ω (manager .QueryProgressReporters (context .Background ())).Should (Equal ([]string {"A" , "C" }))
31
+ Ω (manager .QueryProgressReporters (context .Background (), nil )).Should (Equal ([]string {"A" , "C" }))
31
32
cancelA ()
32
- Ω (manager .QueryProgressReporters (context .Background ())).Should (Equal ([]string {"C" }))
33
+ Ω (manager .QueryProgressReporters (context .Background (), nil )).Should (Equal ([]string {"C" }))
33
34
cancelC ()
34
- Ω (manager .QueryProgressReporters (context .Background ())).Should (BeEmpty ())
35
+ Ω (manager .QueryProgressReporters (context .Background (), nil )).Should (BeEmpty ())
35
36
})
36
37
37
38
It ("bails if a progress reporter takes longer than the passed-in context's deadline" , func () {
@@ -45,11 +46,25 @@ var _ = Describe("ProgressReporterManager", func() {
45
46
})
46
47
manager .AttachProgressReporter (func () string { return "D" })
47
48
context , cancel := context .WithTimeout (context .Background (), time .Millisecond * 100 )
48
- result := manager .QueryProgressReporters (context )
49
+ result := manager .QueryProgressReporters (context , nil )
49
50
Ω (result ).Should (Equal ([]string {"A" , "B" }))
50
51
cancel ()
51
52
close (c )
52
53
53
54
Eventually (gleak .Goroutines ).ShouldNot (gleak .HaveLeaked (startingGoroutines ))
54
55
})
56
+
57
+ It ("catches panics and reports them as failures" , func () {
58
+ manager .AttachProgressReporter (func () string {
59
+ panic ("bam" )
60
+ })
61
+ manager .AttachProgressReporter (func () string { return "B" })
62
+ failer := internal .NewFailer ()
63
+ result := manager .QueryProgressReporters (context .Background (), failer )
64
+ Ω (result ).Should (Equal ([]string {"failed to query attached progress reporter" , "B" }))
65
+ state , failure := failer .Drain ()
66
+ Ω (state ).Should (Equal (types .SpecStatePanicked ))
67
+ Ω (failure .Message ).Should (Equal ("Test Panicked" ))
68
+ Ω (failure .ForwardedPanic ).Should (Equal ("bam" ))
69
+ })
55
70
})
0 commit comments