#!/bin/sh
# This script is invoked by tarmac - the automatic branch lader - before it
# allows a merge request to land into trunk
set -e

# Destroy VMs after we're done with each image. This works around
# a bug in virtualbox shared folder filesystem.
export VAGRANT_DONE_ACTION=destroy
# Which test runner/container to use. We default to LXC but
# honor an external env variable to set this.
TEST_RUNNER=${TEST_RUNNER:-lxc}
# Use tmpfs for the lxc containers, faster but requires more RAM (about 2 GB)
# NOTE: Needs to be a non-empty blank string due to weird ${param:-default}
# semantics
export KEEP_DATA=" "
# Run checkbox tests, plainbox tests, integration tests and plainbox docs
if [ "$TEST_RUNNER" = "vagrant" ]; then
    time -o timing.dat ./test-in-vagrant.sh
else
    time -o timing.dat ./test-in-lxc.sh
fi
# Vagrant testing can be done with this line
echo "Complete checkbox, plainbox, integration and docs time:"
cat timing.dat

# Ping rtfd.org to refresh the documentation
curl -X POST http://readthedocs.org/build/plainbox
curl -X POST http://readthedocs.org/build/checkbox
