#!/usr/bin/env bash

# Source common test setup
source "$(dirname "${0}")/test_common.sh";

#####################
# Begin Script Body #
#####################

errors=();
if [ "${#}" -ne 0 ]; then
  targets="$@";
else
  targets="$(\ls "$(dirname "${0}")" | grep 'test_')";
fi;

for t in ${targets}; do
  bash "$(dirname "${0}")/${t}" \
    || errors+=( "${t}" );
done;

if [ "${#errors[@]}" -ne 0 ]; then
  log 'warn' '===== The following test suites failed =====';
  for error in "${errors[@]}"; do
    log 'warn' "\t${error}";
  done;
  log 'error' 'Test suite failure(s)';
  # log 'error' exits 1, but be explicit in case log behaviour changes
  exit 1;
else
  log 'info' 'All test suites passed.';
fi;

exit 0;
# vi: set ts=2 sw=2 et:
