#! /usr/bin/env sh

set -u

EXIT_STATUS=0

check_program() {
   prog="$1"
   echo -n "checking for ${prog}... "
   type "$prog" > /dev/null 2> /dev/null
   if [ $? -eq 0 ];then
      echo "yes"
   else
      echo "no"
      EXIT_STATUS=1
   fi
}

check_program "cargo"
check_program "robot"
check_program "git"
check_program "curl"
check_program "tar"
check_program "bzip2"
check_program "gzip"
check_program "xz"
check_program "unzip"
check_program "md5sum"
check_program "sha1sum"
check_program "sha256sum"
check_program "sha512sum"

set -e


if [ "$EXIT_STATUS" -ne 0 ]; then
   final_msg="
***
*** Your system's configuration seems invalid to execute subcomponent's tests.
*** Please make sure that all the checks above pass before trying to run the
*** tests.
***
"
else
   final_msg="
Your system seems able to run the tests :)
"
fi

echo "$final_msg"
exit "$EXIT_STATUS"
