adds top level json generation with stats

This commit is contained in:
Todd Treece 2015-07-29 10:29:56 -04:00
parent 4718f90879
commit 2f0d958e14

View file

@ -40,9 +40,7 @@ arduino --install-boards adafruit:avr > /dev/null
# see: https://github.com/arduino/Arduino/issues/3535 # see: https://github.com/arduino/Arduino/issues/3535
arduino --install-library USBHost arduino --install-library USBHost
# init human readable status and json status vars # init the json temp var for the current platform
export STATUS_OUTPUT=""
export STATUS_JSON=""
export PLATFORM_JSON="" export PLATFORM_JSON=""
# init test stats counters # init test stats counters
@ -58,6 +56,9 @@ function build_platform()
eval $MAIN_PLATFORMS eval $MAIN_PLATFORMS
eval $AUX_PLATFORMS eval $AUX_PLATFORMS
# reset platform json var
PLATFORM_JSON=""
# expects argument 1 to be the platform key # expects argument 1 to be the platform key
local platform_key=$1 local platform_key=$1
@ -181,11 +182,11 @@ function json_sketch()
local last_sketch=$3 local last_sketch=$3
# echo out the json # echo out the json
echo "\"$sketch\": $status_number" echo -n "\"$sketch\": $status_number"
# echo a comma unless this is the last sketch for the platform # echo a comma unless this is the last sketch for the platform
if [ "$last_sketch" -ne "1" ]; then if [ "$last_sketch" -ne "1" ]; then
echo ", " echo -n ", "
fi fi
} }
@ -206,12 +207,37 @@ function json_platform()
# is this the last platform we are building? 0: no, 1: yes # is this the last platform we are building? 0: no, 1: yes
local last_platform=$3 local last_platform=$3
echo "\"$platform_key\": { \"status\": $status_number, \"builds\": $sketch_json }" echo -n "\"$platform_key\": { \"status\": $status_number, \"builds\": $sketch_json }"
# echo a comma unless this is the last sketch for the platform # echo a comma unless this is the last sketch for the platform
if [ "$last_platform" -ne "1" ]; then if [ "$last_platform" -ne "1" ]; then
echo ", " echo -n ", "
fi fi
} }
# generate final json string
function json_main_platforms()
{
# 0: failed, 1: passed
local status_number=$2
# the json string for the main platforms
local platforms_json=$3
local repo=$(git config --get remote.origin.url)
echo "|||||||||||||||||||| JSON STATUS ||||||||||||||||||||"
echo -n "{ \"repo\": \"$repo\", "
echo -n "\"status\": $status_number, "
echo -n "\"passed\": $PASSED_COUNT, "
echo -n "\"skipped\": $SKIPPED_COUNT, "
echo -n "\"failed\": $FAILED_COUNT, "
echo "\"platforms\": $platforms_json }"
echo "|||||||||||||||||||| JSON STATUS ||||||||||||||||||||"
}