From 169ebfa72c73e24ab14fef8fc1d2eb4a622ee095 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Fri, 12 Feb 2021 16:38:58 +0000 Subject: [PATCH] test: make-deps: Add folds around tests and dep blocks Improves readability of CI test output and hides away the complexity when in most cases it is not required. Retain fold behaviour for both Travis and GitHub Actions in case both are used in any capacity. Signed-off-by: Joe Groocock --- misc/make-deps.sh | 11 +++++++++++ test.sh | 16 ++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/misc/make-deps.sh b/misc/make-deps.sh index a2f430fa..af1720c2 100755 --- a/misc/make-deps.sh +++ b/misc/make-deps.sh @@ -44,6 +44,7 @@ if [ -n "$YUM" -a -n "$APT" ]; then echo "You have both $APT and $YUM installed. Please check your deps manually." fi +fold_start "Install dependencies" if [ -n "$YUM" ]; then $sudo_command $YUM install -y libvirt-devel $sudo_command $YUM install -y augeas-devel @@ -78,6 +79,7 @@ fi if [ -n "$PACMAN" ]; then $sudo_command $PACMAN -S --noconfirm --asdeps --needed libvirt augeas rubygems libpcap fi +fold_end "Install dependencies" if ! in_ci; then if [ -n "$YUM" ]; then @@ -118,11 +120,15 @@ if [ "$goversion" -lt "$mingoversion" ]; then exit 1 fi +fold_start "Install Go dependencies" echo "running 'go get -v -d ./...' from `pwd`" go get -v -t -d ./... # get all the go dependencies echo "done running 'go get -v -t -d ./...'" +fold_end "Install Go dependencies" [ -e "$GOBIN/mgmt" ] && rm -f "$GOBIN/mgmt" # the `go get` version has no -X + +fold_start "Install Go tools" go get github.com/blynn/nex # for lexing go get golang.org/x/tools/cmd/goyacc # formerly `go tool yacc` go get golang.org/x/tools/cmd/stringer # for automatic stringer-ing @@ -135,6 +141,11 @@ if in_ci; then mv "$(dirname $(command -v gometalinter.v1))/gometalinter.v1" "$(dirname $(command -v gometalinter.v1))/gometalinter" && \ gometalinter --install # bonus fi +fold_end "Install Go tools" + +fold_start "Install miscellaneous tools" command -v mdl &>/dev/null || gem install mdl --no-document || true # for linting markdown files command -v fpm &>/dev/null || gem install fpm --no-document || true # for cross distro packaging +fold_end "Install miscellaneous tools" + cd "$XPWD" >/dev/null diff --git a/test.sh b/test.sh index 4e91fc29..7486a5f5 100755 --- a/test.sh +++ b/test.sh @@ -12,9 +12,9 @@ testsuite="$1" # print environment when running all testsuites -fold_start env.1 "environment" -test -z "$testsuite" && (echo "ENV:"; env; echo; ) -fold_end env.1 +fold_start environment +test -z "$testsuite" && (echo "ENV:"; env | sort; echo;) +fold_end environment # make it easy to split test into blocks label-block() { @@ -26,18 +26,18 @@ label-block() { } # run a test and record failures -function run-testsuite() -{ +function run-testsuite() { testname="$(basename "$1" .sh)" # if not running all tests or if this test is not explicitly selected, skip it if test -z "$testsuite" || test "test-$testsuite" = "$testname";then - $@ || failures=$( [ -n "$failures" ] && echo "$failures\\n$@" || echo "$@" ) + fold_start "$testname" + "$@" || failures=$([ -n "$failures" ] && echo "$failures\\n$@" || echo "$@") + fold_end "$testname" fi } # only run test if it is explicitly selected, otherwise report it is skipped -function skip-testsuite() -{ +function skip-testsuite() { testname=$(basename "$1" .sh) # show skip message only when running full suite if test -z "$testsuite";then