Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 64 lines (53 sloc) 1.71 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#!/usr/bin/env bash

# **exercise.sh**

# Keep track of the current devstack directory.
TOP_DIR=$(cd $(dirname "$0") && pwd)

# Import common functions
source $TOP_DIR/functions

# Load local configuration
source $TOP_DIR/stackrc

# 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:-""}

# Locate the scripts we should run
EXERCISE_DIR=$(dirname "$0")/exercises
basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done)

# Track the state of each script
passes=""
failures=""
skips=""

# Loop over each possible script (by basename)
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

# output status of exercise run
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
Something went wrong with that request. Please try again.