#!/bin/zsh
#
# Run basic tests to avoid regressions
#
here=$(dirname $0)
source $here/odoo_scripts_common
# This should not fail
pushd tests/log
for file in *.txt ;
do
  ODOO_TYPE=$(echo -e "$file" | sed -rne "s/([^-]*).*/\1/p")
  echo "****** Using log $file (with ODOO_TYPE=$ODOO_TYPE) ******"
  cat $file | colorize
  analyze $file && return_code=0 || return_code=$?
  if [[ "$file" == *fail* ]];
  then
    if [ "$return_code" -eq 0 ];
    then
      echo $FATAL expected non-zero as return code
      exit 1
    else
      echo $OK exected FATAL message, ignore it
    fi
  else
    if [ "$return_code" -ne 0 ];
    then
      echo $FATAL expected zero as return code
      exit 1
    fi
  fi
done
popd
