34 Commits

Author SHA1 Message Date
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Samuele Pedroni
f83b1f1560 many: progress bars should use the overridable stdouts (#12047)
making progress bars should take a stdout io.Writer

ToolingStore should carry an overridable stdout

make sure in image, preseed and cmd/snap code the overridable
top-level Stdout is passed along to make progress bars
2022-08-18 11:34:35 +02:00
Maciej Borzecki
d127b295c1 many: use the helper for checking current binary is a test one
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-07-17 17:55:35 +02:00
Ian Johnson
588875e19f many: use more specific check for unit test mocking
Currently, if you try to use a snap with an app named "test", os.Args will also
end in ".test", making numerous places in the codebase think that it is being
run in a test environment and behave differently. In the case of the reported
bug, the code panics from `snap run` as it seems to the mountinfo code that we
are not mocking something that we should always be mocking in unit tests.

The bug could still hypothetically happen if someone made a symlink from 
somewhere with "go-build" in the path (but not as part of the app name in the
snap) and a .test suffix on the executable, but this is sufficiently specific
that it is highly unlikely we would ever actually run into that problem "in the
wild".

Fixes: https://bugs.launchpad.net/snapd/+bug/1886786

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-07-08 06:55:51 -05:00
John R. Lenton
06e83b2e0e add unit tests for ansimeter; some tweaks for quantity corner cases 2017-10-06 13:54:57 +01:00
John R. Lenton
e67a2c0ddc many: implement our own ANSI-escape-using progress indicator
This introduces a `progress.Meter` written from "scratch" (mostly based on
previous work and experiments I did on IO progress bars and fixed-width
displays). It's called `progress.ANSIMeter`.

We were using a `progress.NullProgress` in situations where we actually didn't
want progress bars but still wanted notifications, so `progress.QuietMeter` is a
`progress.Meter` that does that, and that is returned by
`progress.MakeProgressBar()` when it doesn't think we have an actual terminal.

We were replacing `os.Stdout` to look at the output of progress bars, so I wrote
`progresstest.Meter` that just records what it's told instead of printing it
anywhere, and use it in some places.

I renamed `progress.NullProgress` to `progress.NullMeter`, and added
`progress.Null` as a default `progress.NullMeter`; as it's a `struct{}`, it
doesn't make sense not to use that (we were using `&progress.NullMeter{}` in
many many tests).

`image` was not calling `Finished()` on the progress bar, so I added code for it to
do that both in the sane case and in the case the user `^C`'s out.
2017-09-25 17:36:11 -04:00
Michael Hudson-Doyle
f033646f3d switch to canonical path for gopkg.in/cheggaaa/pb.v1
this will let me remove a particularly silly bit of the debian delta.
2017-08-15 13:32:26 +12:00
John R. Lenton
fc5e6d7112 build snapd without CGO 2016-11-23 22:49:52 +00:00
Michael Vogt
9139ec872d init pbar with correct total value 2016-11-22 08:56:56 +01:00
Leo Arias
f16ada711d static tests: add spell check 2016-11-16 22:31:16 +00:00
Michael Vogt
8d75a516a5 use New64 and fix output newline 2016-09-23 08:05:53 +02:00
Michael Vogt
6e423da936 Merge remote-tracking branch 'upstream/master' into feature/snap-download-lp1584590 2016-09-22 15:46:02 +02:00
Michael Vogt
76aba0c274 rename "progress.Info -> progress.Label" 2016-09-22 07:47:16 +02:00
Michael Vogt
21d188f2a3 fix extra newline after progress done 2016-09-21 11:49:10 +02:00
Michael Vogt
18ba69f612 Show snap name before the download progress bar
This requires that we expand the TaskProgress to include an additional
info string that can be set independently from the change so that
for changes that download multiple packages we get the right data.

LP: #1584590
2016-09-21 10:28:11 +02:00
Samuele Pedroni
10255cf410 super unlikely that it will still be mediated through Meter.Agreed in the daemon 2016-05-06 17:08:44 +02:00
Michael Vogt
d4a9088a65 Merge remote-tracking branch 'upstream/master' into bugfix/umount-failure 2016-05-02 16:42:06 +02:00
Michael Vogt
1e0b967112 clear last task line when the progress is finished 2016-04-28 14:58:42 +02:00
Michael Vogt
54cb5010c3 fix Notify() output/tests 2016-04-28 07:43:22 +02:00
Michael Vogt
a88e1001c5 add status output in notify 2016-04-27 21:41:29 +02:00
Michael Vogt
f0b1d39320 show the spinner before the text and add space 2016-04-14 18:39:23 +02:00
Michael Vogt
df88e23073 Make the progress less chatty
As discussed during the sprint we present some unneeded information
in the progress dialog (like starting and done).
2015-12-08 16:31:45 +01:00
John R. Lenton
b79daba99c works. Next: tests 2015-11-13 19:12:54 +00:00
Michael Vogt
97b274a12a merged lp:~mvo/snappy/snappy-lp1449032-poor-mans-rsync-15.04 2015-06-03 13:48:37 +02:00
Michael Vogt
583b342a39 progress/progress.go: make spinner clear its line 2015-05-29 14:24:04 +02:00