2015-03-07 18:19:15 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2015-12-07 15:43:16 +01:00
|
|
|
function echo_to_log {
|
2015-06-02 16:06:41 -07:00
|
|
|
echo "$BATS_TEST_NAME
|
2015-03-20 21:59:04 -04:00
|
|
|
----------
|
|
|
|
|
$output
|
|
|
|
|
----------
|
|
|
|
|
|
2015-06-02 16:06:41 -07:00
|
|
|
" >> ${BATS_LOG}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-07 15:43:16 +01:00
|
|
|
function teardown {
|
2015-09-02 13:42:13 -07:00
|
|
|
echo_to_log
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-07 15:43:16 +01:00
|
|
|
function errecho {
|
2015-06-02 16:06:41 -07:00
|
|
|
>&2 echo "$@"
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-07 15:43:16 +01:00
|
|
|
function only_if_env {
|
2015-06-02 16:06:41 -07:00
|
|
|
if [[ ${!1} != "$2" ]]; then
|
2015-11-25 23:01:47 -08:00
|
|
|
errecho "This test requires the $1 environment variable to be set to $2. Skipping..."
|
|
|
|
|
skip
|
2015-06-02 16:06:41 -07:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-07 15:43:16 +01:00
|
|
|
function require_env {
|
2015-06-02 16:06:41 -07:00
|
|
|
if [[ -z ${!1} ]]; then
|
|
|
|
|
errecho "This test requires the $1 environment variable to be set in order to run."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2015-03-20 21:59:04 -04:00
|
|
|
}
|
2015-08-27 19:07:39 +09:00
|
|
|
|
2015-12-07 17:13:13 +01:00
|
|
|
function use_disposable_machine {
|
|
|
|
|
if [[ -z "$NAME" ]]; then
|
|
|
|
|
export NAME="bats-$DRIVER-test-$(date +%s)"
|
|
|
|
|
fi
|
2015-12-07 15:43:16 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-07 17:13:13 +01:00
|
|
|
function use_shared_machine {
|
|
|
|
|
if [[ -z "$NAME" ]]; then
|
|
|
|
|
export NAME="$SHARED_NAME"
|
|
|
|
|
if [[ $(machine ls -q --filter name=$NAME | wc -l) -eq 0 ]]; then
|
|
|
|
|
machine create -d $DRIVER $NAME &>/dev/null
|
|
|
|
|
fi
|
2015-12-07 15:43:16 +01:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-27 19:07:39 +09:00
|
|
|
# Make sure these aren't set while tests run (can cause confusing behavior)
|
|
|
|
|
unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_DIR
|