From f75ac13a4f7754efcc9fb88558e5723f77017c4d Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 14 Mar 2018 20:32:47 +0000 Subject: [PATCH] Travis CI: folded output/default tracebacks (#1331) * Moved the `script` and `after_failure` sections of `.travis.yml` to extra files in a new `.travis/` folder * Copy paste `.travis/common.sh` from Alpine's aport. They have neat formatting functions in there for folding * Add a folding block around each script that gets called * Use native tracebacks in pytest. These are the same as we see when pmbootstrap crashes usually, instead of printing out the entire function that causes an error. I think this makes the error output easier to read. --- .travis.yml | 9 ++----- .travis/common.sh | 45 +++++++++++++++++++++++++++++++++ .travis/travis_after_failure.sh | 18 +++++++++++++ .travis/travis_script.sh | 33 ++++++++++++++++++++++++ test/testcases_fast.sh | 2 +- 5 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 .travis/common.sh create mode 100755 .travis/travis_after_failure.sh create mode 100755 .travis/travis_script.sh diff --git a/.travis.yml b/.travis.yml index 66b2a87a..5443671e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,10 @@ install: - sudo apt install shellcheck qemu-system-x86 - pip install flake8 pytest-cov python-coveralls script: - - test/static_code_analysis.sh - - yes "" | ./pmbootstrap.py init - - ./pmbootstrap.py kconfig_check - - test/check_checksums.py --build - - test/testcases_fast.sh --all + - .travis/travis_script.sh after_success: - coveralls after_failure: - - cat ~/.local/var/pmbootstrap/log.txt - - cat ~/.local/var/pmbootstrap/log_testsuite.txt + - .travis/travis_after_failure.sh notifications: - email: false diff --git a/.travis/common.sh b/.travis/common.sh new file mode 100644 index 00000000..97f7f4b2 --- /dev/null +++ b/.travis/common.sh @@ -0,0 +1,45 @@ +# Source: .travis/common.sh from Alpine's aports repo + +die() { + print -s1 -c1 "$@\n" 1>&2 + exit 1 +} + +# Marks start of named folding section for Travis and prints title. +fold_start() { + local name="$1" + local title="$2" + + printf "\ntravis_fold:start:$name " + print -s1 -c6 "> $title\n" +} + +# Marks end of the named folding section. +fold_end() { + local name="$1" + + printf "travis_fold:end:$name\n" +} + +# Prints formatted and colored text. +print() { + local style=0 + local fcolor=9 + + local opt; while getopts 's:c:' opt; do + case "$opt" in + s) style="$OPTARG";; + c) fcolor="$OPTARG";; + esac + done + + shift $(( OPTIND - 1 )) + local text="$@" + + printf "\033[${style};3${fcolor}m$text\033[0m" +} + +title() { + printf '\n' + print -s1 -c6 "==> $@\n" +} diff --git a/.travis/travis_after_failure.sh b/.travis/travis_after_failure.sh new file mode 100755 index 00000000..d37fa7f6 --- /dev/null +++ b/.travis/travis_after_failure.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e + +# Go to pmbootstrap folder +DIR="$(cd "$(dirname "$0")" && pwd -P)" +cd "$DIR/.." + +# Functions for pretty Travis output +. .travis/common.sh + +# pmbootstrap log +fold_start "log.1" "pmbootstrap log" +cat ~/.local/var/pmbootstrap/log.txt +fold_end "log.1" + +# Testsuite log +fold_start "log.2" "Testsuite log" +cat ~/.local/var/pmbootstrap/log_testsuite.txt +fold_end "log.2" diff --git a/.travis/travis_script.sh b/.travis/travis_script.sh new file mode 100755 index 00000000..6669e845 --- /dev/null +++ b/.travis/travis_script.sh @@ -0,0 +1,33 @@ +#!/bin/sh -e + +# Go to pmbootstrap folder +DIR="$(cd "$(dirname "$0")" && pwd -P)" +cd "$DIR/.." + +# Functions for pretty Travis output +. .travis/common.sh + +# Static code analysis +fold_start "static_analysis" "Static code analysis" +test/static_code_analysis.sh +fold_end "static_analysis" + +# pmbootstrap init +fold_start "init" "pmbootstrap init" +yes "" | ./pmbootstrap.py init +fold_end "init" + +# pmbootstrap kconfig_check +fold_start "kconfig_check" "pmbootstrap kconfig_check" +./pmbootstrap.py kconfig_check +fold_end "kconfig_check" + +# pmbootstrap build --strict +fold_start "build" "pmbootstrap build --strict" +test/check_checksums.py --build +fold_end "build" + +# Testsuite +fold_start "testsuite" "Testsuite and code coverage" +test/testcases_fast.sh --all +fold_end "testsuite" diff --git a/test/testcases_fast.sh b/test/testcases_fast.sh index c80f7aef..01aef9da 100755 --- a/test/testcases_fast.sh +++ b/test/testcases_fast.sh @@ -35,4 +35,4 @@ done # Run enabled testcases with coverage enabled # shellcheck disable=SC2086 -pytest --cov=pmb $enabled +pytest --cov=pmb $enabled --tb=native