#!/bin/bash -l

set -ex

export PATH=/var/vcap/packages/cf-cli-8-linux/bin:${PATH} # put the cf cli on the path
export CONFIG=/var/vcap/jobs/smoke_tests/bin/config.json

ACCEPTANCE_BIN=/var/vcap/packages/acceptance_tests/bin

mkdir -p /var/vcap/sys/log/smoke_tests

EXITSTATUS=0
verbose=<%= properties.acceptance_tests.verbose ? "-v" : "" %>

"${ACCEPTANCE_BIN}/ginkgo" "${ACCEPTANCE_BIN}/smoke.test" \
  -randomize-all $verbose -keep-going || EXITSTATUS=$?

echo "Smoke Tests Complete; exit status: $EXITSTATUS"

for i in /var/vcap/sys/log/smoke_tests/*.txt; do
  if [ -e "$i" ]; then
    mv $i $i.log # needed to make download-logs work
  fi
done

exit $EXITSTATUS
