1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-30 07:17:59 +00:00

Update 'mftest' (local test build) script

This commit is contained in:
Scott Lahteine 2019-10-06 21:03:11 -05:00
parent 9188ce1a8d
commit 4134c6398a

View File

@ -11,11 +11,13 @@ MFINFO=$(mfinfo) || exit 1
[[ -d Marlin/src ]] || { echo "Please 'cd' up to repo root." ; exit 1 ; } [[ -d Marlin/src ]] || { echo "Please 'cd' up to repo root." ; exit 1 ; }
TESTPATH=buildroot/share/tests TESTPATH=buildroot/share/tests
STATE_FILE=$( echo ./.pio/.mftestrc )
shopt -s extglob nocasematch shopt -s extglob nocasematch
# Get test # Get the environment and test number from the command
TESTENV=${1:-'-'} TESTENV=${1:-'-'}
CHOICE=${2:-0}
# Allow shorthand for test name # Allow shorthand for test name
case $TESTENV in case $TESTENV in
@ -37,6 +39,15 @@ case $TESTENV in
t32) TESTENV='teensy31' ;; t32) TESTENV='teensy31' ;;
t35) TESTENV='teensy35' ;; t35) TESTENV='teensy35' ;;
t36) TESTENV='teensy35' ;; t36) TESTENV='teensy35' ;;
# Build with the last-built env
-r) [[ -f "$STATE_FILE" ]] || { echo "No previous (-r) build state found." ; exit 1 ; }
read TESTENV <"$STATE_FILE"
platformio run --project-dir . -e $TESTENV
exit
;;
# A -y may come first
-y) TESTENV=${2:-'-'} ; CHOICE=${3:-0} ;;
-[a-z]) echo "Unknown flag $TESTENV" ; exit 1 ;;
-) ;; -) ;;
esac esac
@ -77,9 +88,6 @@ OUT=$( cat $TESTPATH/$TESTENV-tests 2>/dev/null ) || { echo "Can't find test '$T
# TODO: List test descriptions with numbers # TODO: List test descriptions with numbers
TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" ) TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" )
# Get the entered or interactive test index
CHOICE=${2:-0}
# User entered a number? # User entered a number?
(( CHOICE && CHOICE > TESTCOUNT )) && { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; } (( CHOICE && CHOICE > TESTCOUNT )) && { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
@ -135,6 +143,16 @@ echo "$OUT" | {
done done
} }
# Get a -y parameter the lazy way
[[ "$2" == "-y" || "$3" == "-y" ]] && BUILD_YES='Y'
# Build the test too? # Build the test too?
echo ; read -p "Build $TESTENV test #$CHOICE (y/N) ? " BUILD_YES if [[ $BUILD_YES != 'Y' ]]; then
[[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && platformio run --project-dir . -e $TESTENV echo
read -p "Build $TESTENV test #$CHOICE (y/N) ? " BUILD_YES
fi
[[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && {
platformio run --project-dir . -e $TESTENV
echo "$TESTENV" >"$STATE_FILE"
}