Codebase list golang-github-vbauerster-mpb / 57df464
simplify TestWithContext Vladimir Bauer 4 years ago
1 changed file(s) with 3 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
9494 p := mpb.NewWithContext(ctx, mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(ioutil.Discard))
9595
9696 done := make(chan struct{})
97 fail := make(chan struct{})
9897 bar := p.AddBar(0) // never complete bar
9998 go func() {
10099 for !bar.Aborted() {
105104 }()
106105
107106 go func() {
108 select {
109 case <-done:
110 p.Wait()
111 case <-time.After(timeout):
112 close(fail)
113 }
107 <-done
108 p.Wait()
114109 }()
115110
116111 select {
117112 case <-shutdown:
118 case <-fail:
113 case <-time.After(timeout):
119114 t.Errorf("Progress didn't shutdown after %v", timeout)
120115 }
121116 }