#!/bin/bash

green="\033[0;32m"
red="\033[0;31m"
nc="\033[0m"

overall_exit_code=0

while read test; do
    echo $test

    dir=$(dirname $test)
    test=$(basename $dir)

    make -C $dir "$@"
    exit_code=$?

    if [[ $exit_code -ne 0 ]]; then
        tput bold
        echo -e "${red}Failed: ${test} ($@)${nc}"
        overall_exit_code=1
    else
        tput bold
        echo -e "${green}Succeeded: ${test} ($@)${nc}"
    fi
done < <(ls -1 it/test-*/Makefile)

exit $overall_exit_code
