#!/bin/zsh
#function t_setup {
  0=${(%):-%x}
  local prjdir="${0:A:h:h:h}"
  local testdir="${0:A:h:h}"

  # save fpath
  typeset -g T_PREV_FPATH=( $fpath )

  # save zstyles, and clear them all for the test session
  typeset -ga T_PREV_ZSTYLES=( ${(@f)"$(zstyle -L ':antidote:*')"} )
  source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}')

  # setup test functions
  fpath+=( $testdir/functions )
  autoload -Uz $testdir/functions/*

  # mock git
  function git { mockgit "$@" }

  # works with BSD and GNU gmktemp
  T_TEMPDIR=${$(mktemp -d -t t_antidote.XXXXXXXX):A}

  # put zdotdir in position
  cp -rf $testdir/zdotdir $T_TEMPDIR
  local mockdir
  for mockdir in $T_TEMPDIR/**/.mock*; do
    mv $mockdir ${mockdir:s/.mock/.}
  done
  typeset -g OLD_ZDOTDIR=$ZDOTDIR
  export ZDOTDIR=$T_TEMPDIR/zdotdir

  # our mock plugins use this
  typeset -ga plugins=()
  typeset -ga libs=()

  # setup antidote
  zstyle ':antidote:tests' set-warn-options 'on'
  zstyle ':antidote:tests' cloning 'off'

  # load antidote
  typeset -g ANTIDOTE_HOME=$ZDOTDIR/antidote_home
#}
