1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
summary: Verify progress reporting from snap command
details: |
Verify that progress reporting from snap command works as expected depending
on whether the command is ran with a tty attached or not.
execute: |
echo "Minimal status reported when stdout is redirected"
# no stdin, stdout to a pipe
snap install test-snapd-tools-core24 </dev/null | tee -a non-tty-install.log
snap remove test-snapd-tools-core24 </dev/null | tee -a non-tty-remove.log
# a single summary line for both operations
test "$(wc -l < non-tty-install.log)" = "1"
MATCH "test-snapd-tools-core24 .* installed" < non-tty-install.log
test "$(wc -l < non-tty-remove.log)" = "1"
MATCH "test-snapd-tools-core24 removed" < non-tty-remove.log
echo "Rich status reporting when stdout is on a tty"
(
# work around progress.go check for SPREAD_SYSTEM
unset SPREAD_SYSTEM;
faketty() {
script -qefc "$(printf "%q " "$@")" /dev/null
}
faketty snap install test-snapd-tools-core24 | tr '\r' '\n' > tty-install.log
faketty snap remove test-snapd-tools-core24 | tr '\r' '\n' > tty-remove.log
)
# more than one line for each operation
test "$(wc -l < tty-install.log)" -gt "1"
test "$(wc -l < tty-remove.log)" -gt "1"
# expecting multiple status messages and a summary, but we cannot check for
# every status message as the client only displays a currently running task
# and may have missed short lived tasks
# XXX relax or drop this check if fails randomly
MATCH "(Fetch|Mount|Setup)" < tty-install.log
MATCH "test-snapd-tools-core24 .* installed" < tty-install.log
MATCH "Remove snap" < tty-remove.log
MATCH "test-snapd-tools-core24 removed" < tty-remove.log
|