exercise.sh

exercise.sh

# DIVIDER #!/usr/bin/env bash # DIVIDER TOP_DIR=$(cd $(dirname "$0") && pwd) # DIVIDER source $TOP_DIR/functions # DIVIDER source $TOP_DIR/stackrc # DIVIDER # DIVIDER SKIP_EXERCISES=${SKIP_EXERCISES:-""} # DIVIDER basenames=${RUN_EXERCISES:-""} EXERCISE_DIR=$TOP_DIR/exercises if [[ -z "${basenames}" ]]; then # DIVIDER basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done) else # DIVIDER SKIP_EXERCISES= fi # DIVIDER passes="" failures="" skips="" # DIVIDER for script in $basenames; do if [[ ,$SKIP_EXERCISES, =~ ,$script, ]]; then skips="$skips $script" else echo "=====================================================================" echo Running $script echo "=====================================================================" $EXERCISE_DIR/$script.sh exitcode=$? if [[ $exitcode == 55 ]]; then skips="$skips $script" elif [[ $exitcode -ne 0 ]]; then failures="$failures $script" else passes="$passes $script" fi fi done # DIVIDER echo "=====================================================================" for script in $skips; do echo SKIP $script done for script in $passes; do echo PASS $script done for script in $failures; do echo FAILED $script done echo "=====================================================================" if [[ -n "$failures" ]]; then exit 1 fi # DIVIDER

Keep track of the current DevStack directory.

Import common functions

Load local configuration

Run everything in the exercises/ directory that isn't explicitly disabled

comma separated list of script basenames to skip to refrain from exercising euca.sh use SKIP_EXERCISES=euca

comma separated list of script basenames to run to run only euca.sh use RUN_EXERCISES=euca

Locate the scripts we should run

If RUN_EXERCISES was specified, ignore SKIP_EXERCISES.

Track the state of each script

Loop over each possible script (by basename)

Output status of exercise run