From 73341a0f8450619b595a2d05dac9e52dc8465741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 2 Jun 2020 11:28:07 +0200 Subject: [PATCH 1/3] Add a --quiet option to all.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The primary purpose is to use it to run all.sh -k -q in the pre-push hook, but this can be useful in any circumstance where you're not interested in the full output from each component and just want a short summary of which components were run (and if any failed). Note that only stdout from components is suppressed, stderr is preserved so that errors are reported. This means components should avoid printing to stderr in normal usage (ie in the absence of errors). Currently all the `check_*` components obey this convention except: - check_generate_test_code: unittest prints progress to stderr - check_test_cases: lots of non-fatal warnings printed to stderr These components will be fixed in follow-up commits. Signed-off-by: Manuel Pégourié-Gonnard --- tests/scripts/all.sh | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index c580dd0f0..8ab44d0cb 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -158,6 +158,7 @@ pre_initialize_variables () { MEMORY=0 FORCE=0 + QUIET=0 KEEP_GOING=0 YOTTA=1 @@ -238,6 +239,7 @@ Special options: --list-components List components supported on this platform and exit. General options: + -q|--quiet Only output component names, and errors if any. -f|--force Force the tests to overwrite any modified files. -k|--keep-going Run all tests and report errors at the end. -m|--memory Additional optional memory tests. @@ -252,6 +254,7 @@ General options: --no-keep-going Stop at the first error (default). --no-memory No additional memory tests (default). --no-yotta Skip yotta module build. + --no-quiet Print full ouput from components. --out-of-source-dir= Directory used for CMake out-of-source build tests. --random-seed Use a random seed value for randomized tests (default). -r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}. @@ -318,6 +321,11 @@ msg() else current_section="$1" fi + + if [ $QUIET -eq 1 ]; then + return + fi + echo "" echo "******************************************************************" echo "* $current_section " @@ -381,9 +389,11 @@ pre_parse_command_line () { --no-keep-going) KEEP_GOING=0;; --no-memory) MEMORY=0;; --no-yotta) YOTTA=0;; + --no-quiet) QUIET=0;; --openssl) shift; OPENSSL="$1";; --openssl-legacy) shift; OPENSSL_LEGACY="$1";; --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; + --quiet|-q) QUIET=1;; --random-seed) unset SEED;; --release-test|-r) SEED=$RELEASE_SEED;; --seed|-s) shift; SEED="$1";; @@ -478,7 +488,7 @@ pre_setup_keep_going () { failure_summary="$failure_summary $text" failure_count=$((failure_count + 1)) - echo "${start_red}^^^^$text^^^^${end_color}" + echo "${start_red}^^^^$text^^^^${end_color}" >&2 fi } make () { @@ -524,8 +534,23 @@ not() { ! "$@" } +pre_setup_quiet_redirect () { + if [ $QUIET -ne 1 ]; then + redirect_out () { + "$@" + } + else + redirect_out () { + "$@" >/dev/null + } + fi +} pre_print_configuration () { + if [ $QUIET -eq 1 ]; then + return + fi + msg "info: $0 configuration" echo "MEMORY: $MEMORY" echo "FORCE: $FORCE" @@ -593,6 +618,11 @@ pre_check_tools () { "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; esac + # past this point, no call to check_tool, only printing output + if [ $QUIET -eq 1 ]; then + return + fi + msg "info: output_env.sh" case $RUN_COMPONENTS in *_armcc*|*_yotta*) @@ -1384,8 +1414,17 @@ run_component () { # The cleanup function will restore it. cp -p "$CONFIG_H" "$CONFIG_BAK" current_component="$1" - "$@" + + # Run the component code. + if [ $QUIET -eq 1 ]; then + # msg() is silenced, so just print the component name here + echo "${current_component#component_}" + fi + redirect_out "$@" + + # Restore the build tree to a clean state. cleanup + current_component="" } # Preliminary setup @@ -1402,6 +1441,7 @@ else "$@" } fi +pre_setup_quiet_redirect pre_print_configuration pre_check_tools cleanup From 4f265fbff79e6368a0bbf1ab7c38907ee8d5c474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 2 Jun 2020 11:54:25 +0200 Subject: [PATCH 2/3] Use all.sh in pre-push hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The list in the pre-push hook was redundant with the list of `check_*` components in all.sh, and unsurprisingly it was outdated. Missing components were: - check_recursion - check_changelog - check_test_cases - check_python_files - check_generate_test_code Signed-off-by: Manuel Pégourié-Gonnard --- tests/git-scripts/pre-push.sh | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/tests/git-scripts/pre-push.sh b/tests/git-scripts/pre-push.sh index 120084293..fd283c8fe 100755 --- a/tests/git-scripts/pre-push.sh +++ b/tests/git-scripts/pre-push.sh @@ -72,18 +72,4 @@ echo "URL is $URL" set -eu -run_test() -{ - TEST=$1 - echo "running '$TEST'" - if ! `$TEST > /dev/null 2>&1`; then - echo "test '$TEST' failed" - return 1 - fi -} - -run_test ./tests/scripts/check-doxy-blocks.pl -run_test ./tests/scripts/check-names.sh -run_test ./tests/scripts/check-generated-files.sh -run_test ./tests/scripts/check-files.py -run_test ./tests/scripts/doxygen.sh +tests/scripts/all.sh -q -k 'check_*' From c09bb4c3abbc66109f700bd3d6b20ad6174ca644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 8 Jun 2020 10:59:41 +0200 Subject: [PATCH 3/3] all.sh: clean up some uses of "local" variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While pure sh doesn't have a concept of local variables, we can partially emulate them by unsetting variables before we exit the function, and use the convention of giving them lowercase names to distinguish from global variables. Signed-off-by: Manuel Pégourié-Gonnard --- tests/scripts/all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 8ab44d0cb..62ba53feb 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1424,7 +1424,7 @@ run_component () { # Restore the build tree to a clean state. cleanup - current_component="" + unset current_component } # Preliminary setup