Fix test script formatting

This commit is contained in:
Daniel 2019-08-20 21:25:22 +02:00
parent c36f3a7307
commit c2d7ba143e
2 changed files with 17 additions and 7 deletions

View file

@ -9,4 +9,4 @@ install:
- go install github.com/golang/dep/cmd/dep - go install github.com/golang/dep/cmd/dep
- dep ensure - dep ensure
script: ./test script: ./test --scripted

22
test
View file

@ -2,9 +2,13 @@
warnings=0 warnings=0
errors=0 errors=0
scripted=0
goUp="\\e[1A"
function run { function run {
echo "[......] $*" if [[ $scripted -eq 0 ]]; then
echo "[......] $*"
fi
# create tmpfile # create tmpfile
tmpfile=$(mktemp) tmpfile=$(mktemp)
@ -16,10 +20,10 @@ function run {
# check return code # check return code
if [[ $rc -eq 0 ]]; then if [[ $rc -eq 0 ]]; then
if [[ $output == *"[no test files]"* ]]; then if [[ $output == *"[no test files]"* ]]; then
echo -e "\e[1A[\e[01;33mNOTEST\e[00m] $*" echo -e "${goUp}[\e[01;33mNOTEST\e[00m] $*"
warnings=$((warnings+1)) warnings=$((warnings+1))
else else
echo -ne "\e[1A[\e[01;32m OK \e[00m] " echo -ne "${goUp}[\e[01;32m OK \e[00m] "
if [[ $2 == "test" ]]; then if [[ $2 == "test" ]]; then
echo -n $* echo -n $*
echo -n ": " echo -n ": "
@ -30,10 +34,10 @@ function run {
fi fi
else else
if [[ $output == *"build constraints exclude all Go files"* ]]; then if [[ $output == *"build constraints exclude all Go files"* ]]; then
echo -e "\e[1A[ !OS ] $*" echo -e "${goUp}[ !OS ] $*"
warnings=$((warnings+1)) warnings=$((warnings+1))
else else
echo -e "\e[1A[\e[01;31m FAIL \e[00m] $*" >/dev/stderr echo -e "${goUp}[\e[01;31m FAIL \e[00m] $*" >/dev/stderr
cat $tmpfile >/dev/stderr cat $tmpfile >/dev/stderr
errors=$((errors+1)) errors=$((errors+1))
fi fi
@ -46,9 +50,15 @@ function run {
baseDir="$( cd "$(dirname "$0")" && pwd )" baseDir="$( cd "$(dirname "$0")" && pwd )"
cd "$baseDir" cd "$baseDir"
# change output format if being run in script
if [[ $1 == "--scripted" ]]; then
scripted=1
goUp=""
fi
# platform info # platform info
platformInfo=$(go env GOOS GOARCH) platformInfo=$(go env GOOS GOARCH)
echo "running tests for ${platformInfo//$'\n'/ }" echo "running tests for ${platformInfo//$'\n'/ }:"
# get all packages # get all packages
packages=$(go list ./...) packages=$(go list ./...)