Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 1 | #!/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 |
| 7 | SKIP_EXERCISES=${SKIP_EXERCISES:-""} |
| 8 | |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 9 | # Locate the scripts we should run |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 10 | EXERCISE_DIR=$(dirname "$0")/exercises |
Todd Willey | 0367cf1 | 2011-11-05 10:46:56 -0400 | [diff] [blame] | 11 | basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done) |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 12 | |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 13 | # Track the state of each script |
| 14 | passes="" |
| 15 | failures="" |
| 16 | skips="" |
| 17 | |
| 18 | # Loop over each possible script (by basename) |
Todd Willey | 0367cf1 | 2011-11-05 10:46:56 -0400 | [diff] [blame] | 19 | for script in $basenames; do |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 20 | if [[ "$SKIP_EXERCISES" =~ $script ]] ; then |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 21 | skips="$skips $script" |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 22 | else |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 23 | echo ========================= |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 24 | echo Running $script |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 25 | echo ========================= |
| 26 | $EXERCISE_DIR/$script.sh |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 27 | if [[ $? -ne 0 ]] ; then |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 28 | failures="$failures $script" |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 29 | else |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 30 | passes="$passes $script" |
Todd Willey | 2599b31 | 2011-11-04 10:31:37 -0400 | [diff] [blame] | 31 | fi |
| 32 | fi |
| 33 | done |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 34 | |
| 35 | # output status of exercise run |
| 36 | echo ========================= |
| 37 | echo ========================= |
Todd Willey | 0367cf1 | 2011-11-05 10:46:56 -0400 | [diff] [blame] | 38 | for script in $skips; do |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 39 | echo SKIP $script |
| 40 | done |
Todd Willey | 0367cf1 | 2011-11-05 10:46:56 -0400 | [diff] [blame] | 41 | for script in $passes; do |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 42 | echo PASS $script |
| 43 | done |
Todd Willey | 0367cf1 | 2011-11-05 10:46:56 -0400 | [diff] [blame] | 44 | for script in $failures; do |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 45 | echo FAILED $script |
| 46 | done |