From fa749bc354ef12cd3ddcd40c1cb215cbc6624997 Mon Sep 17 00:00:00 2001 From: Castulo Martinez Date: Tue, 24 Dec 2019 11:46:09 -0800 Subject: [PATCH] Cleaning the spinner once download completes A spinner was added to swupd to show some kind of progress while downloading content which its amount is unknown. Once the content is downloaded the stopped spinner should be removed from the screen. This commit does that. Signed-off-by: Castulo Martinez --- src/curl.c | 14 +- src/progress.c | 10 ++ src/progress.h | 5 + test/functional/diagnose/diagnose-json.bats | 144 +++++++++---------- test/functional/os-install/install-json.bats | 4 +- test/functional/repair/repair-json.bats | 10 +- test/functional/testlib.bash | 24 ++-- 7 files changed, 121 insertions(+), 90 deletions(-) diff --git a/src/curl.c b/src/curl.c index e9e51ad9..edc04580 100644 --- a/src/curl.c +++ b/src/curl.c @@ -681,7 +681,12 @@ static int retry_download_loop(const char *url, char *filename, struct curl_file */ int swupd_curl_get_file(const char *url, char *filename) { - return retry_download_loop(url, filename, NULL, false); + int ret; + + ret = retry_download_loop(url, filename, NULL, false); + clean_spinner(); + + return ret; } /* @@ -691,7 +696,12 @@ int swupd_curl_get_file(const char *url, char *filename) */ int swupd_curl_get_file_memory(const char *url, struct curl_file_data *file_data) { - return retry_download_loop(url, NULL, file_data, false); + int ret; + + ret = retry_download_loop(url, NULL, file_data, false); + clean_spinner(); + + return ret; } static CURLcode swupd_curl_set_security_opts(CURL *curl) diff --git a/src/progress.c b/src/progress.c index 503d2fd7..b42a9783 100644 --- a/src/progress.c +++ b/src/progress.c @@ -49,6 +49,13 @@ struct spinner_data { int index; } spinner_data; +void clean_spinner(void) +{ + if (current_type == PROGRESS_UNDEFINED) { + info(" \r"); + } +} + static int progress_spinner_callback(void *clientp, int64_t UNUSED_PARAM dltotal, int64_t UNUSED_PARAM dlnow, int64_t UNUSED_PARAM ultotal, int64_t UNUSED_PARAM ulnow) { const char spinner[4] = { '|', '/', '-', '\\' }; @@ -70,6 +77,9 @@ static void progress_spinner_end(void) return; } + /* clean the spinner from the screen */ + clean_spinner(); + swupd_curl_download_set_progress_callback(NULL, NULL); } diff --git a/src/progress.h b/src/progress.h index c0c75177..bc9a71a3 100644 --- a/src/progress.h +++ b/src/progress.h @@ -85,6 +85,11 @@ void progress_report(double count, double max); */ void progress_set_enabled(bool enabled); +/** + * @brief Cleans a spinner from the screen. + */ +void clean_spinner(void); + #ifdef __cplusplus } #endif diff --git a/test/functional/diagnose/diagnose-json.bats b/test/functional/diagnose/diagnose-json.bats index b295f9a8..b40185d5 100755 --- a/test/functional/diagnose/diagnose-json.bats +++ b/test/functional/diagnose/diagnose-json.bats @@ -22,79 +22,79 @@ test_setup() { assert_status_is "$SWUPD_NO" expected_output=$(cat <<-EOM - \[ - \{ "type" : "start", "section" : "diagnose" \}, - \{ "type" : "progress", "currentStep" : 1, "totalSteps" : 4, "stepCompletion" : -1, "stepDescription" : "load_manifests" \}, - \{ "type" : "info", "msg" : "Diagnosing version 10" \}, - \{ "type" : "info", "msg" : "Downloading missing manifests..." \}, - \{ "type" : "progress", "currentStep" : 1, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "load_manifests" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 0, "stepDescription" : "add_missing_files" \}, - \{ "type" : "info", "msg" : " Checking for missing files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 5, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 11, "stepDescription" : "add_missing_files" \}, - \{ "type" : "info", "msg" : " -> Missing file: .*/baz" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 17, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 23, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 29, "stepDescription" : "add_missing_files" \}, - \{ "type" : "info", "msg" : " -> Missing file: .*/foo/test-file1" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 35, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 41, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 47, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 52, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 58, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 64, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 70, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 76, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 82, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 88, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 94, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "add_missing_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 0, "stepDescription" : "fix_files" \}, - \{ "type" : "info", "msg" : " Checking for corrupt files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 5, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 11, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 17, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 23, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 29, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 35, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 41, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 47, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 52, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 58, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 64, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 70, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 76, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 82, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 88, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 94, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "fix_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 0, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "info", "msg" : " Checking for extraneous files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 5, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 11, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 17, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 23, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 29, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 35, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 41, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 47, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 52, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 58, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 64, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 70, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 76, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 82, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 88, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 94, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "remove_extraneous_files" \}, - \{ "type" : "info", "msg" : " Inspected 17 files" \}, - \{ "type" : "info", "msg" : " 2 files were missing" \}, - \{ "type" : "info", "msg" : " Use 'swupd repair' to correct the problems in the system" \}, - \{ "type" : "info", "msg" : " Diagnose successful" \}, - \{ "type" : "end", "section" : "diagnose", "status" : 1 \} - \] + [ + { "type" : "start", "section" : "diagnose" }, + { "type" : "progress", "currentStep" : 1, "totalSteps" : 4, "stepCompletion" : -1, "stepDescription" : "load_manifests" }, + { "type" : "info", "msg" : "Diagnosing version 10" }, + { "type" : "info", "msg" : "Downloading missing manifests..." }, + { "type" : "progress", "currentStep" : 1, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "load_manifests" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 0, "stepDescription" : "add_missing_files" }, + { "type" : "info", "msg" : " Checking for missing files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 5, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 11, "stepDescription" : "add_missing_files" }, + { "type" : "info", "msg" : " -> Missing file: $PATH_PREFIX/baz" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 17, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 23, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 29, "stepDescription" : "add_missing_files" }, + { "type" : "info", "msg" : " -> Missing file: $PATH_PREFIX/foo/test-file1" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 35, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 41, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 47, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 52, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 58, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 64, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 70, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 76, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 82, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 88, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 94, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "add_missing_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 0, "stepDescription" : "fix_files" }, + { "type" : "info", "msg" : "Checking for corrupt files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 5, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 11, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 17, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 23, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 29, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 35, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 41, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 47, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 52, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 58, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 64, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 70, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 76, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 82, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 88, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 94, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 3, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "fix_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 0, "stepDescription" : "remove_extraneous_files" }, + { "type" : "info", "msg" : "Checking for extraneous files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 5, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 11, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 17, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 23, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 29, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 35, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 41, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 47, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 52, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 58, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 64, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 70, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 76, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 82, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 88, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 94, "stepDescription" : "remove_extraneous_files" }, + { "type" : "progress", "currentStep" : 4, "totalSteps" : 4, "stepCompletion" : 100, "stepDescription" : "remove_extraneous_files" }, + { "type" : "info", "msg" : "Inspected 17 files" }, + { "type" : "info", "msg" : " 2 files were missing" }, + { "type" : "info", "msg" : " Use 'swupd repair' to correct the problems in the system" }, + { "type" : "info", "msg" : " Diagnose successful" }, + { "type" : "end", "section" : "diagnose", "status" : 1 } + ] EOM ) - assert_regex_in_output "$expected_output" + assert_is_output "$expected_output" } diff --git a/test/functional/os-install/install-json.bats b/test/functional/os-install/install-json.bats index 76768451..c1176926 100755 --- a/test/functional/os-install/install-json.bats +++ b/test/functional/os-install/install-json.bats @@ -52,10 +52,10 @@ test_setup() { { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : -1, "stepDescription" : "extract_fullfiles" }, { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : 100, "stepDescription" : "extract_fullfiles" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 0, "stepDescription" : "add_missing_files" }, - { "type" : "info", "msg" : " Installing base OS and selected bundles" }, + { "type" : "info", "msg" : "Installing base OS and selected bundles" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 50, "stepDescription" : "add_missing_files" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 100, "stepDescription" : "add_missing_files" }, - { "type" : "info", "msg" : " Inspected 2 files" }, + { "type" : "info", "msg" : "Inspected 2 files" }, { "type" : "info", "msg" : " 2 files were missing" }, { "type" : "info", "msg" : " 2 of 2 missing files were installed" }, { "type" : "info", "msg" : " 0 of 2 missing files were not installed" }, diff --git a/test/functional/repair/repair-json.bats b/test/functional/repair/repair-json.bats index be5744b1..0d2c3bb1 100755 --- a/test/functional/repair/repair-json.bats +++ b/test/functional/repair/repair-json.bats @@ -75,7 +75,7 @@ test_setup() { { "type" : "progress", "currentStep" : 5, "totalSteps" : 9, "stepCompletion" : -1, "stepDescription" : "extract_fullfiles" }, { "type" : "progress", "currentStep" : 5, "totalSteps" : 9, "stepCompletion" : 100, "stepDescription" : "extract_fullfiles" }, { "type" : "progress", "currentStep" : 6, "totalSteps" : 9, "stepCompletion" : 0, "stepDescription" : "add_missing_files" }, - { "type" : "info", "msg" : " Adding any missing files" }, + { "type" : "info", "msg" : "Adding any missing files" }, { "type" : "progress", "currentStep" : 6, "totalSteps" : 9, "stepCompletion" : 5, "stepDescription" : "add_missing_files" }, { "type" : "progress", "currentStep" : 6, "totalSteps" : 9, "stepCompletion" : 11, "stepDescription" : "add_missing_files" }, { "type" : "info", "msg" : " -> Missing file: $PATH_PREFIX/baz" }, @@ -98,7 +98,7 @@ test_setup() { { "type" : "progress", "currentStep" : 6, "totalSteps" : 9, "stepCompletion" : 94, "stepDescription" : "add_missing_files" }, { "type" : "progress", "currentStep" : 6, "totalSteps" : 9, "stepCompletion" : 100, "stepDescription" : "add_missing_files" }, { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : 0, "stepDescription" : "fix_files" }, - { "type" : "info", "msg" : " Repairing corrupt files" }, + { "type" : "info", "msg" : "Repairing corrupt files" }, { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : 5, "stepDescription" : "fix_files" }, { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : 11, "stepDescription" : "fix_files" }, { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : 17, "stepDescription" : "fix_files" }, @@ -117,7 +117,7 @@ test_setup() { { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : 94, "stepDescription" : "fix_files" }, { "type" : "progress", "currentStep" : 7, "totalSteps" : 9, "stepCompletion" : 100, "stepDescription" : "fix_files" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 0, "stepDescription" : "remove_extraneous_files" }, - { "type" : "info", "msg" : " Removing extraneous files" }, + { "type" : "info", "msg" : "Removing extraneous files" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 5, "stepDescription" : "remove_extraneous_files" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 11, "stepDescription" : "remove_extraneous_files" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 17, "stepDescription" : "remove_extraneous_files" }, @@ -136,14 +136,14 @@ test_setup() { { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 94, "stepDescription" : "remove_extraneous_files" }, { "type" : "progress", "currentStep" : 8, "totalSteps" : 9, "stepCompletion" : 100, "stepDescription" : "remove_extraneous_files" }, { "type" : "progress", "currentStep" : 9, "totalSteps" : 9, "stepCompletion" : 0, "stepDescription" : "remove_extra_files" }, - { "type" : "info", "msg" : " Removing extra files under $PATH_PREFIX/usr" }, + { "type" : "info", "msg" : "Removing extra files under $PATH_PREFIX/usr" }, { "type" : "info", "msg" : " -> Extra file: $PATH_PREFIX/usr/share/defaults/swupd/versionurl" }, { "type" : "info", "msg" : " -> deleted" }, { "type" : "info", "msg" : " -> Extra file: $PATH_PREFIX/usr/share/defaults/swupd/contenturl" }, { "type" : "info", "msg" : " -> deleted" }, { "type" : "info", "msg" : " -> Extra file: $PATH_PREFIX/usr/extraneous-file" }, { "type" : "info", "msg" : " -> deleted" }, - { "type" : "info", "msg" : " Inspected 20 files" }, + { "type" : "info", "msg" : "Inspected 20 files" }, { "type" : "info", "msg" : " 2 files were missing" }, { "type" : "info", "msg" : " 2 of 2 missing files were replaced" }, { "type" : "info", "msg" : " 0 of 2 missing files were not replaced" }, diff --git a/test/functional/testlib.bash b/test/functional/testlib.bash index 5a51620e..eb5808a7 100644 --- a/test/functional/testlib.bash +++ b/test/functional/testlib.bash @@ -3612,10 +3612,15 @@ use_ignore_list() { local filtered_output validate_param "$ignore_enabled" + # remove the " \r" that could have been inserted to the output when + # cleaning up the spinner (this should be done regardless of if we are + # filtering more things otherwise the assertions would fail) + filtered_output="$(printf "%s" "$output" | sed 's/ \r//g')" + # if selected, remove things in the ignore list from the actual output if [ "$ignore_enabled" = true ]; then - # always remove blank lines, lines with only dots and lines with progress percentage - filtered_output=$(echo "$output" | sed -E '/^$/d' | sed -E '/^\.+$/d' | sed -E '/^\t\.\.\.[0-9]{1,3}%$/d') + # always remove blank lines, lines with only dots or spaces and lines with progress percentage + filtered_output=$(echo "$filtered_output" | sed -E '/^$/d' | sed -E '/^\.+$/d' | sed -E '/^\t\.\.\.[0-9]{1,3}%$/d') # now remove lines that are included in any of the ignore-lists # there are 3 possible ignore-lists that the function is going # to recognize (in order of precedence): @@ -3638,8 +3643,9 @@ use_ignore_list() { done < "$ignore_list" else debug_msg "The use of ignore lists is disabled" - filtered_output="$output" + filtered_output="$filtered_output" fi + echo "$filtered_output" } @@ -3793,7 +3799,7 @@ assert_is_output() { # assertion if [[ ! "$actual_output" == "$expected_output" ]]; then print_assert_failure "The following text was not the command output:\\n$sep\\n$expected_output\\n$sep" echo -e "Difference:\\n$sep" - diff -u <(echo "$expected_output") <(echo "$actual_output") + diff -u <(echo -e "$expected_output") <(echo -e "$actual_output") || true return 1 fi @@ -3812,7 +3818,7 @@ assert_is_not_output() { # assertion if [[ "$actual_output" == "$expected_output" ]]; then print_assert_failure "The following text was the command output and should not have:\\n$sep\\n$expected_output\\n$sep" echo -e "Difference:\\n$sep" - diff -u <(echo "$expected_output") <(echo "$actual_output") + diff -u <(echo "$expected_output") <(echo "$actual_output") || true return 1 fi @@ -3831,7 +3837,7 @@ assert_regex_in_output() { # assertion if [[ ! "$actual_output" =~ $expected_output ]]; then print_assert_failure "The following text (regex) was not found in the command output:\\n$sep\\n$expected_output\\n$sep" echo -e "Difference:\\n$sep" - diff -u <(echo "$expected_output") <(echo "$actual_output") + diff -u <(echo "$expected_output") <(echo "$actual_output") || true return 1 fi @@ -3850,7 +3856,7 @@ assert_regex_not_in_output() { # assertion if [[ "$actual_output" =~ $expected_output ]]; then print_assert_failure "The following text (regex) was found in the command output and should not have:\\n$sep\\n$expected_output\\n$sep" echo -e "Difference:\\n$sep" - diff -u <(echo "$expected_output") <(echo "$actual_output") + diff -u <(echo "$expected_output") <(echo "$actual_output") || true return 1 fi @@ -3869,7 +3875,7 @@ assert_regex_is_output() { # assertion if [[ ! "$actual_output" =~ ^$expected_output$ ]]; then print_assert_failure "The following text (regex) was not the command output:\\n$sep\\n$expected_output\\n$sep" echo -e "Difference:\\n$sep" - diff -u <(echo "$expected_output") <(echo "$actual_output") + diff -u <(echo "$expected_output") <(echo "$actual_output") || true return 1 fi @@ -3888,7 +3894,7 @@ assert_regex_is_not_output() { # assertion if [[ "$actual_output" =~ ^$expected_output$ ]]; then print_assert_failure "The following text (regex) was the command output and should not have:\\n$sep\\n$expected_output\\n$sep" echo -e "Difference:\\n$sep" - diff -u <(echo "$expected_output") <(echo "$actual_output") + diff -u <(echo "$expected_output") <(echo "$actual_output") || true return 1 fi