#!/bin/bash
set -eu
THIS="$(readlink -f "$0")"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
temp=""
pushed=n

setupTests() {
  temp=$(mktemp -d -t XXXXX)
  pushd "${temp}" >/dev/null
  pushed=y
  mkdir -p src/.git
  echo "echo This is a test" > src/startup.sh
}

tearDown() {
  if test "${pushed}" = y; then
    popd >/dev/null || true
  fi
  if test -n "${temp}"; then
    rm -rf "${temp}"
  fi
  temp=""
  pushed=n
}

testTarExtraOpts() {
  setupTests

  tar_extra="--verbose --exclude .git"
  ${SUT} --tar-extra "$tar_extra" src src.sh alabel startup.sh

  assertEquals $? 0

  tearDown
}

# Load and run shUnit2.
source "./shunit2/shunit2"

