Skip to content

Instantly share code, notes, and snippets.

@chris-zen
Forked from nlochschmidt/travis-run-tests.sh
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-zen/5d8d7968b6932c70965b to your computer and use it in GitHub Desktop.
Save chris-zen/5d8d7968b6932c70965b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0
# Adapted from https://github.com/paulp/psp-std/blob/master/bin/test
runTests () {
sbt test || exit 1
echo "[info] $(date) - finished sbt test"
}
stripTerminalEscapeCodes () {
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGKM]//g"
}
mkRegex () { ( IFS="|" && echo "$*" ); }
filterOutput() {
while read line; do
if ! [[ $(echo $line | stripTerminalEscapeCodes) =~ $excludeRegex ]] ; then
echo $line
fi
done
}
main() {
# sbt output filter
local excludeRegex=$(mkRegex \
'\[info\] (Resolving|Loading|Updating|Packaging|Done updating)' \
're[-]run with [-]unchecked for details' \
'one warning found'
)
echo "[info] $(date) - starting sbt test"
(set -o pipefail && runTests |& filterOutput)
}
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment