exercise.sh
2599b316
 #!/usr/bin/env bash
 
c639ef01
 source ./stackrc
2599b316
 # 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
 SKIP_EXERCISES=${SKIP_EXERCISES:-""}
 
9e9132dd
 # Locate the scripts we should run
2599b316
 EXERCISE_DIR=$(dirname "$0")/exercises
0367cf15
 basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done)
2599b316
 
9e9132dd
 # Track the state of each script
 passes=""
 failures=""
 skips=""
 
 # Loop over each possible script (by basename)
0367cf15
 for script in $basenames; do
2599b316
     if [[ "$SKIP_EXERCISES" =~ $script ]] ; then
9e9132dd
         skips="$skips $script"
2599b316
     else
9e9132dd
         echo =========================
2599b316
         echo Running $script
9e9132dd
         echo =========================
         $EXERCISE_DIR/$script.sh
2599b316
         if [[ $? -ne 0 ]] ; then
9e9132dd
             failures="$failures $script"
2599b316
         else
9e9132dd
             passes="$passes $script"
2599b316
         fi
     fi
 done
9e9132dd
 
 # output status of exercise run
 echo =========================
 echo =========================
0367cf15
 for script in $skips; do
9e9132dd
     echo SKIP $script
 done
0367cf15
 for script in $passes; do
9e9132dd
     echo PASS $script
 done
0367cf15
 for script in $failures; do
9e9132dd
     echo FAILED $script
 done
c639ef01
 
 if [ -n "$failures" ] ; then
     exit 1
 fi