#! /bin/sh
# $Id: run-test-suite 299 2006-09-13 09:53:39Z sfsetse $

myName=`basename $0`

SHELLS='/bin/sh /bin/bash /bin/ksh'

[ $# -ne 0 ] && shells=$@ || shells=${SHELLS}

first=1
for shell in ${shells}; do
  # check for existance of shell
  if [ ! -x ${shell} ]; then
    echo "${myName}:WARN unable to run tests with the ${shell} shell"
    continue
  fi

  # separate test runs with a blank line
  if [ ${first} -eq 0 ]; then
    echo
  else
    first=0
  fi

  echo "#------------------------------------------------------------------------------"
  echo "# Running the test suite with ${shell}"
  echo "#"

  for suite in test[A-Z]*; do
    if [ -x ${suite} ]; then
      # execute the test
      suiteName=`expr "${suite}" : 'test\(.*\)'`
      echo
      echo "--- Executing the '${suiteName}' test suite ---" >&2
      ( exec ${shell} ./${suite} )
    fi
  done
done
