diff --git a/.gitignore b/.gitignore index 275a4b6..250273f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ /bin/dub-* # Ignore files or directories created by the test suite. +/test/test.log /test/custom-source-main-bug487/custom-source-main-bug487 /test/3-copyFiles/bin/ /test/ignore-hidden-1/ignore-hidden-1 diff --git a/test/common.sh b/test/common.sh index 7bd2a27..eba424d 100644 --- a/test/common.sh +++ b/test/common.sh @@ -2,12 +2,17 @@ set -ueEo pipefail +function log() { + echo -e "\033[0;33m[INFO] $@\033[0m" + echo "[INFO] $@" >> $(dirname "${BASH_SOURCE[0]}")/test.log +} + # lineno[, msg] function die() { local line=$1 local msg=${2:-command failed} local supplemental=${3:-} - >&2 echo "[ERROR] $SOURCE_FILE:$1 $msg" + echo "[ERROR] $SOURCE_FILE:$1 $msg" | tee -a $(dirname "${BASH_SOURCE[0]}")/test.log | cat 1>&2 if [ ! -z "$supplemental" ]; then echo "$supplemental" | >&2 sed 's|^| |g' fi diff --git a/test/run-unittest.sh b/test/run-unittest.sh index 8d14e33..5f27b93 100755 --- a/test/run-unittest.sh +++ b/test/run-unittest.sh @@ -3,12 +3,16 @@ . $(dirname "${BASH_SOURCE[0]}")/common.sh +> $(dirname "${BASH_SOURCE[0]}")/test.log + function log() { echo -e "\033[0;33m[INFO] $@\033[0m" + echo "[INFO] $@" >> $(dirname "${BASH_SOURCE[0]}")/test.log } function logError() { echo -e 1>&2 "\033[0;31m[ERROR] $@\033[0m" + echo "[ERROR] $@" >> $(dirname "${BASH_SOURCE[0]}")/test.log any_errors=1 } @@ -33,7 +37,10 @@ CURR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) FRONTEND="${FRONTEND:-}" +if [ "$#" -gt 0 ]; then FILTER=$1; else FILTER=".*"; fi + for script in $(ls $CURR_DIR/*.sh); do + if [[ ! "$script" =~ $FILTER ]]; then continue; fi if [ "$script" = "$(readlink -f ${BASH_SOURCE[0]})" ] || [ "$(basename $script)" = "common.sh" ]; then continue; fi if [ -e $script.min_frontend ] && [ ! -z "$FRONTEND" ] && [ ${FRONTEND} \< $(cat $script.min_frontend) ]; then continue; fi log "Running $script..." @@ -41,6 +48,7 @@ done for pack in $(ls -d $CURR_DIR/*/); do + if [[ ! "$pack" =~ $FILTER ]]; then continue; fi if [ -e $pack/.min_frontend ] && [ ! -z "$FRONTEND" -a "$FRONTEND" \< $(cat $pack/.min_frontend) ]; then continue; fi # First we build the packages @@ -70,4 +78,8 @@ fi done +echo +echo 'Testing summary:' +cat $(dirname "${BASH_SOURCE[0]}")/test.log + exit ${any_errors:-0}