#!/bin/bash
# TODO
# check to make sure the specified test case and filename exist
# eg:  TEST_CASE.py exists and includes function TEST_CASE
#
# Arguments
# 1: Name of test - mandatory
# 2: Incremental - optional, pass --incremental for incremental

incremental_flag=''
# Check for incremental flag
if [ ! -z "$2" ]
then
  # Argument 2 was supplied, need to verify that it is actually --incremental
  if [ $2 = "--incremental" ]
  then
    # Add a leading space to the flag
    incremental_flag=" $2"
  else
    # we have a problem, the user typed something incorrectly
    echo "Error in argument '$2'"
    echo ""
    echo "Expected '--incremental' or no flag if incremental is not desired"
    echo ""
    exit 1
  fi
fi



branch=$(git rev-parse --abbrev-ref HEAD)
sha=$(git rev-parse $branch)

echo ""
echo "current branch:  $branch"
echo "current SHA:     $sha"

echo ""

cmd="ci/zimbeast/run_hil_test.py --deploy $sha --zstart-opts '--local --kraken$incremental_flag' ci/zimbeast/test_scripts/sensor_monitor_tests/$1.py::$1"
echo $cmd
exit 0

if [ "$#" -ne 1 ]; then
    echo "You must specify the test case name, eg:"
    echo "   $0 TEST_CASE"
    exit
fi

cd ~/driving
eval "$cmd"
