fix import paths
Vladimir Bauer
7 years ago
| 6 | 6 | "sync" |
| 7 | 7 | "time" |
| 8 | 8 | |
| 9 | "github.com/vbauerster/mpb" | |
| 10 | "github.com/vbauerster/mpb/decor" | |
| 9 | "github.com/vbauerster/mpb/v4" | |
| 10 | "github.com/vbauerster/mpb/v4/decor" | |
| 11 | 11 | ) |
| 12 | 12 | |
| 13 | 13 | func init() { |
| 10 | 10 | "time" |
| 11 | 11 | "unicode/utf8" |
| 12 | 12 | |
| 13 | "github.com/vbauerster/mpb/decor" | |
| 13 | "github.com/vbauerster/mpb/v4/decor" | |
| 14 | 14 | ) |
| 15 | 15 | |
| 16 | 16 | // Bar represents a progress Bar |
| 3 | 3 | "io" |
| 4 | 4 | "strings" |
| 5 | 5 | |
| 6 | "github.com/vbauerster/mpb/decor" | |
| 7 | "github.com/vbauerster/mpb/internal" | |
| 6 | "github.com/vbauerster/mpb/v4/decor" | |
| 7 | "github.com/vbauerster/mpb/v4/internal" | |
| 8 | 8 | ) |
| 9 | 9 | |
| 10 | 10 | const ( |
| 3 | 3 | "io" |
| 4 | 4 | "unicode/utf8" |
| 5 | 5 | |
| 6 | "github.com/vbauerster/mpb/decor" | |
| 6 | "github.com/vbauerster/mpb/v4/decor" | |
| 7 | 7 | ) |
| 8 | 8 | |
| 9 | 9 | // BarOption is a function option which changes the default behavior of a bar. |
| 8 | 8 | "time" |
| 9 | 9 | "unicode/utf8" |
| 10 | 10 | |
| 11 | . "github.com/vbauerster/mpb" | |
| 12 | "github.com/vbauerster/mpb/decor" | |
| 11 | "github.com/vbauerster/mpb/v4" | |
| 12 | "github.com/vbauerster/mpb/v4/decor" | |
| 13 | 13 | ) |
| 14 | 14 | |
| 15 | 15 | func TestBarCompleted(t *testing.T) { |
| 16 | p := New(WithOutput(ioutil.Discard)) | |
| 16 | p := mpb.New(mpb.WithOutput(ioutil.Discard)) | |
| 17 | 17 | total := 80 |
| 18 | 18 | bar := p.AddBar(int64(total)) |
| 19 | 19 | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | func TestBarID(t *testing.T) { |
| 34 | p := New(WithOutput(ioutil.Discard)) | |
| 34 | p := mpb.New(mpb.WithOutput(ioutil.Discard)) | |
| 35 | 35 | total := 80 |
| 36 | 36 | wantID := 11 |
| 37 | bar := p.AddBar(int64(total), BarID(wantID)) | |
| 37 | bar := p.AddBar(int64(total), mpb.BarID(wantID)) | |
| 38 | 38 | |
| 39 | 39 | go func() { |
| 40 | 40 | for i := 0; i < total; i++ { |
| 56 | 56 | var buf bytes.Buffer |
| 57 | 57 | |
| 58 | 58 | width := 100 |
| 59 | p := New(WithOutput(&buf), WithWidth(width)) | |
| 59 | p := mpb.New(mpb.WithOutput(&buf), mpb.WithWidth(width)) | |
| 60 | 60 | |
| 61 | 61 | total := 100 |
| 62 | 62 | till := 30 |
| 63 | 63 | refillRune := '+' |
| 64 | 64 | |
| 65 | bar := p.AddBar(int64(total), TrimSpace()) | |
| 65 | bar := p.AddBar(int64(total), mpb.TrimSpace()) | |
| 66 | 66 | |
| 67 | 67 | bar.SetRefill(till, refillRune) |
| 68 | 68 | bar.IncrBy(till) |
| 89 | 89 | func TestBarStyle(t *testing.T) { |
| 90 | 90 | var buf bytes.Buffer |
| 91 | 91 | customFormat := "╢▌▌░╟" |
| 92 | p := New(WithOutput(&buf)) | |
| 92 | p := mpb.New(mpb.WithOutput(&buf)) | |
| 93 | 93 | total := 80 |
| 94 | bar := p.AddBar(int64(total), BarStyle(customFormat), TrimSpace()) | |
| 94 | bar := p.AddBar(int64(total), mpb.BarStyle(customFormat), mpb.TrimSpace()) | |
| 95 | 95 | |
| 96 | 96 | for i := 0; i < total; i++ { |
| 97 | 97 | bar.Increment() |
| 115 | 115 | |
| 116 | 116 | func TestBarPanics(t *testing.T) { |
| 117 | 117 | var buf bytes.Buffer |
| 118 | p := New(WithDebugOutput(&buf), WithOutput(ioutil.Discard)) | |
| 118 | p := mpb.New(mpb.WithDebugOutput(&buf), mpb.WithOutput(ioutil.Discard)) | |
| 119 | 119 | |
| 120 | 120 | wantPanic := "Upps!!!" |
| 121 | 121 | total := 100 |
| 122 | 122 | |
| 123 | bar := p.AddBar(int64(total), PrependDecorators(panicDecorator(wantPanic))) | |
| 123 | bar := p.AddBar(int64(total), mpb.PrependDecorators(panicDecorator(wantPanic))) | |
| 124 | 124 | |
| 125 | 125 | go func() { |
| 126 | 126 | for i := 0; i < 100; i++ { |
| 3 | 3 | "io/ioutil" |
| 4 | 4 | "testing" |
| 5 | 5 | |
| 6 | "github.com/vbauerster/mpb/decor" | |
| 6 | "github.com/vbauerster/mpb/v4/decor" | |
| 7 | 7 | ) |
| 8 | 8 | |
| 9 | 9 | func BenchmarkIncrSingleBar(b *testing.B) { |
| 5 | 5 | "bytes" |
| 6 | 6 | "testing" |
| 7 | 7 | |
| 8 | . "github.com/vbauerster/mpb/cwriter" | |
| 8 | . "github.com/vbauerster/mpb/v4/cwriter" | |
| 9 | 9 | ) |
| 10 | 10 | |
| 11 | 11 | // TestWriterPosix by writing and flushing many times. The output buffer |
| 2 | 2 | import ( |
| 3 | 3 | "fmt" |
| 4 | 4 | |
| 5 | "github.com/vbauerster/mpb/internal" | |
| 5 | "github.com/vbauerster/mpb/v4/internal" | |
| 6 | 6 | ) |
| 7 | 7 | |
| 8 | 8 | // Percentage returns percentage decorator. |
| 3 | 3 | "sync" |
| 4 | 4 | "testing" |
| 5 | 5 | |
| 6 | . "github.com/vbauerster/mpb" | |
| 7 | "github.com/vbauerster/mpb/decor" | |
| 6 | . "github.com/vbauerster/mpb/v4" | |
| 7 | "github.com/vbauerster/mpb/v4/decor" | |
| 8 | 8 | ) |
| 9 | 9 | |
| 10 | 10 | func TestNameDecorator(t *testing.T) { |
| 2 | 2 | require ( |
| 3 | 3 | github.com/VividCortex/ewma v1.1.1 |
| 4 | 4 | github.com/mattn/go-isatty v0.0.4 |
| 5 | github.com/vbauerster/mpb v3.3.4+incompatible | |
| 6 | 5 | golang.org/x/crypto v0.0.0-20190129170551-bf88e3f4ba72 |
| 7 | 6 | golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc // indirect |
| 8 | 7 | ) |
| 1 | 1 | github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= |
| 2 | 2 | github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= |
| 3 | 3 | github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= |
| 4 | github.com/vbauerster/mpb v3.3.4+incompatible h1:DDIhnwmgTQIDZo+SWlEr5d6mJBxkOLBwCXPzunhEfJ4= | |
| 5 | github.com/vbauerster/mpb v3.3.4+incompatible/go.mod h1:zAHG26FUhVKETRu+MWqYXcI70POlC6N8up9p1dID7SU= | |
| 6 | 4 | golang.org/x/crypto v0.0.0-20190129170551-bf88e3f4ba72 h1:hOSpsWG5LMauyHIJqtLUU+44acN/ft/9cpzc1ynVDyg= |
| 7 | 5 | golang.org/x/crypto v0.0.0-20190129170551-bf88e3f4ba72/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= |
| 8 | 6 | golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc h1:WiYx1rIFmx8c0mXAFtv5D/mHyKe1+jmuP7PViuwqwuQ= |
| 5 | 5 | "sync" |
| 6 | 6 | "time" |
| 7 | 7 | |
| 8 | "github.com/vbauerster/mpb/cwriter" | |
| 8 | "github.com/vbauerster/mpb/v4/cwriter" | |
| 9 | 9 | ) |
| 10 | 10 | |
| 11 | 11 | // ProgressOption is a function option which changes the default |
| 9 | 9 | "sync" |
| 10 | 10 | "time" |
| 11 | 11 | |
| 12 | "github.com/vbauerster/mpb/cwriter" | |
| 12 | "github.com/vbauerster/mpb/v4/cwriter" | |
| 13 | 13 | ) |
| 14 | 14 | |
| 15 | 15 | const ( |
| 9 | 9 | "testing" |
| 10 | 10 | "time" |
| 11 | 11 | |
| 12 | "github.com/vbauerster/mpb" | |
| 13 | . "github.com/vbauerster/mpb" | |
| 14 | "github.com/vbauerster/mpb/cwriter" | |
| 12 | "github.com/vbauerster/mpb/v4" | |
| 13 | "github.com/vbauerster/mpb/v4/cwriter" | |
| 15 | 14 | ) |
| 16 | 15 | |
| 17 | 16 | var ( |
| 25 | 24 | } |
| 26 | 25 | |
| 27 | 26 | func TestBarCount(t *testing.T) { |
| 28 | p := New(WithOutput(ioutil.Discard)) | |
| 27 | p := mpb.New(mpb.WithOutput(ioutil.Discard)) | |
| 29 | 28 | |
| 30 | 29 | var wg sync.WaitGroup |
| 31 | 30 | wg.Add(1) |
| 51 | 50 | } |
| 52 | 51 | |
| 53 | 52 | func TestBarAbort(t *testing.T) { |
| 54 | p := New(WithOutput(ioutil.Discard)) | |
| 53 | p := mpb.New(mpb.WithOutput(ioutil.Discard)) | |
| 55 | 54 | |
| 56 | 55 | var wg sync.WaitGroup |
| 57 | 56 | wg.Add(1) |
| 58 | bars := make([]*Bar, 3) | |
| 57 | bars := make([]*mpb.Bar, 3) | |
| 59 | 58 | for i := 0; i < 3; i++ { |
| 60 | 59 | b := p.AddBar(100) |
| 61 | 60 | bars[i] = b |