Script to do Travis CI test locally

This commit is contained in:
Scott Lahteine 2018-06-06 00:21:30 -05:00
parent cd73e8f825
commit a7b86e3921
1 changed files with 47 additions and 0 deletions

47
buildroot/bin/travis_at_home Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env bash
#
# travis_at_home
#
# Run all Travis test builds at home to save time finding typos
# Make sure to have 'arduino' somewhere in your PATH
#
LOG="travis-out.txt"
cd `dirname "$0"`/../..
TRAVIS_BUILD_DIR=`pwd`
echo $'Tests for '$TRAVIS_BUILD_DIR$' ...\n' >"$LOG"
# Add a temporary execution PATH
export PATH="./buildroot/bin:$PATH"
# Scan .travis.yml and run config/build commands only
X=1
while read P; do
# Command lines start with a hyphen
if [[ $P =~ ^-\ (([^ ]+)(\ .*)?)$ ]]; then
WORD="${BASH_REMATCH[2]}" ; # The first word
CMD="${BASH_REMATCH[1]}" ; # The whole command
RUN=1 ; BUILD=0
case "$WORD" in
cp|opt_*|pins_*|use_*|restore_*|gen*) ;;
build_*) BUILD=1 ;;
*) RUN=0 ;;
esac
# Runnable command
if [[ $RUN == 1 ]]; then
echo "$CMD" >>"$LOG"
RESULT=$( eval "$CMD >>\"$LOG\" 2>&1" )
if [[ $BUILD == 1 ]]; then
echo "--- Build $X done."
echo >>"$LOG"
X=$((X+1))
fi
fi
fi
done <.travis.yml
cd - >/dev/null