#!/usr/bin/env bash

PROJECT_SCRIPTS_DIR=$(realpath "$0")
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5" 0

pushd "${PROJECT_DIST_DIR}"
for APP in ${PROJECT_APP_LIST[@]}; do
  APP_BIN="${APP}_test${PROJECT_APP_BINARY_EXT}"
  if [ -e "./${APP_BIN}" ]; then
    if [ "${PROJECT_IS_MINGW_UNIX}" == "1" ]; then
      wine64 "${PROJECT_DIST_DIR}/${APP_BIN}" || exit 1
    else
      "./${APP_BIN}" || exit 1
    fi
  fi
done
popd
