From 8f8664c96911f75be49b65113275b16e6f55c6e2 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Thu, 17 Jul 2014 22:36:09 +0200 Subject: [PATCH] Enable running test suite via `run` script --- test/run | 22 ++++++++++++++++++---- test/tests/helpers.sh | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/test/run b/test/run index ec36b41..946a9f5 100755 --- a/test/run +++ b/test/run @@ -3,16 +3,30 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" run_vagrant() { - vagrant up --provider=docker + vagrant up } +# Halt vagrant after tests are done running, unless KEEP_RUNNING environment +# variable is set to 'true'. stop_vagrant() { - vagrant halt + if [ -z "$KEEP_RUNNING" ]; then + vagrant halt + fi +} + +test_files() { + ls -1 ./tests/ | # test files are in `./tests/` dir + grep -i '^test' | # test file names start with 'test' + xargs # file names in one line } run_tests() { - # actually this test file should be run inside vagrant - $CURRENT_DIR/tests/test_plugin_installation.sh + local test_file + local test_dir_path="~/tpm/test/tests/" + for test_file in $(test_files); do + echo "Running test: $test_file" + vagrant ssh -c "${test_dir_path}${test_file}" + done } main() { diff --git a/test/tests/helpers.sh b/test/tests/helpers.sh index 6ac67a2..1a604bc 100644 --- a/test/tests/helpers.sh +++ b/test/tests/helpers.sh @@ -44,12 +44,12 @@ fail_helper() { exit_value_helper() { local fail="$1" if [ "$FAIL" == "true" ]; then + echo "FAIL!" echo - echo "Test failed" exit 1 else + echo "SUCCESS" echo - echo "Test finished successfully" exit 0 fi }