#!/usr/bin/env zsh
set -euo pipefail

has_test_selection=0
for arg in "$@"; do
  case "$arg" in
    -only-testing|-only-testing:*|-skip-testing|-skip-testing:*|-testPlan)
      has_test_selection=1
      ;;
  esac
done

xcode_args=("$@")
if (( has_test_selection == 0 )); then
  xcode_args=("-only-testing:ZenttyTests" "${xcode_args[@]}")
fi

script_dir="${0:A:h}"
exec "$script_dir/test-on-virtual-display" "${xcode_args[@]}"
