blob: 7703f4012c27159075a1cbc125c71122f9baf8e8 [file] [log] [blame]
Todd Willey2599b312011-11-04 10:31:37 -04001#!/usr/bin/env bash
2
3# Run everything in the exercises/ directory that isn't explicitly disabled
4
5# comma separated list of script basenames to skip
6# to refrain from exercising euca.sh use SKIP_EXERCISES=euca
7SKIP_EXERCISES=${SKIP_EXERCISES:-""}
8
Todd Willey9e9132d2011-11-04 12:09:54 -04009# Locate the scripts we should run
Todd Willey2599b312011-11-04 10:31:37 -040010EXERCISE_DIR=$(dirname "$0")/exercises
Todd Willey0367cf12011-11-05 10:46:56 -040011basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done)
Todd Willey2599b312011-11-04 10:31:37 -040012
Todd Willey9e9132d2011-11-04 12:09:54 -040013# Track the state of each script
14passes=""
15failures=""
16skips=""
17
18# Loop over each possible script (by basename)
Todd Willey0367cf12011-11-05 10:46:56 -040019for script in $basenames; do
Todd Willey2599b312011-11-04 10:31:37 -040020 if [[ "$SKIP_EXERCISES" =~ $script ]] ; then
Todd Willey9e9132d2011-11-04 12:09:54 -040021 skips="$skips $script"
Todd Willey2599b312011-11-04 10:31:37 -040022 else
Todd Willey9e9132d2011-11-04 12:09:54 -040023 echo =========================
Todd Willey2599b312011-11-04 10:31:37 -040024 echo Running $script
Todd Willey9e9132d2011-11-04 12:09:54 -040025 echo =========================
26 $EXERCISE_DIR/$script.sh
Todd Willey2599b312011-11-04 10:31:37 -040027 if [[ $? -ne 0 ]] ; then
Todd Willey9e9132d2011-11-04 12:09:54 -040028 failures="$failures $script"
Todd Willey2599b312011-11-04 10:31:37 -040029 else
Todd Willey9e9132d2011-11-04 12:09:54 -040030 passes="$passes $script"
Todd Willey2599b312011-11-04 10:31:37 -040031 fi
32 fi
33done
Todd Willey9e9132d2011-11-04 12:09:54 -040034
35# output status of exercise run
36echo =========================
37echo =========================
Todd Willey0367cf12011-11-05 10:46:56 -040038for script in $skips; do
Todd Willey9e9132d2011-11-04 12:09:54 -040039 echo SKIP $script
40done
Todd Willey0367cf12011-11-05 10:46:56 -040041for script in $passes; do
Todd Willey9e9132d2011-11-04 12:09:54 -040042 echo PASS $script
43done
Todd Willey0367cf12011-11-05 10:46:56 -040044for script in $failures; do
Todd Willey9e9132d2011-11-04 12:09:54 -040045 echo FAILED $script
46done