#!/bin/bash
set -e

export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DEST=.

# Temporarly only test on DEFAULT_DOCKER_VERSION
export DOCKER_DAEMON_VERSION="${DEFAULT_DOCKER_VERSION}"

bundle .integration-daemon-start

cp bundles/libcompose-cli venv/bin/docker-compose
. venv/bin/activate

docker-compose --version
cd venv/compose

# if the tests fail, we still want to execute a few cleanup commands
# so we save the result for the exit command at the end.
# the "or" ensures that return code isn't trapped by the parent script.
timeout --foreground 15m py.test -vs --tb=short $ACCEPTANCE_TEST_ARGS tests/acceptance || result=$?

cd -
bundle .integration-daemon-stop

# TODO: exit with $result status when tests are more stable.
return 0
