Codebase list golang-github-vbauerster-mpb / 065b1be
make sure both Abort cases are engaged Vladimir Bauer 4 years ago
1 changed file(s) with 8 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
126126 *mpb.MaxWidthDistributor = makeWrapper(*mpb.MaxWidthDistributor, start, end)
127127
128128 total := 80
129 numBars := 3
129 numBars := 6
130130 p := mpb.New(mpb.WithOutput(ioutil.Discard))
131131 for i := 0; i < numBars; i++ {
132132 bar := p.AddBar(int64(total),
140140 rng := rand.New(rand.NewSource(time.Now().UnixNano()))
141141 for i := 0; i < total; i++ {
142142 start := time.Now()
143 if bar.ID() >= numBars-1 && i >= 42 {
144 bar.Abort(true)
143 if id := bar.ID(); id > 1 && i >= 42 {
144 if id&1 == 1 {
145 bar.Abort(true)
146 } else {
147 bar.Abort(false)
148 }
145149 }
146 time.Sleep((time.Duration(rng.Intn(10)+1) * (10 * time.Millisecond)) / 2)
150 time.Sleep((time.Duration(rng.Intn(10)+1) * (50 * time.Millisecond)) / 2)
147151 bar.Increment()
148152 bar.DecoratorEwmaUpdate(time.Since(start))
149153 }