From e1b299b6d75b6cbece0fec26257d3f6d6e95e494 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Tue, 4 Aug 2015 00:51:49 +0200 Subject: [PATCH] Add '--keep-running' cli option --- CHANGELOG.md | 2 ++ run_tests | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f62a656..3c8fece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ - add `run_tests` helper - change CLI syntax for choosing vagrant machine to run the tests on - enable running just a single test via `run_tests` cli interface +- add `--keep-running` cli option to continue running vagrant after the tests + are done executing ### v0.2.0, 2015-02-22 - `setup` script gitignores `tests/helpers.sh` diff --git a/run_tests b/run_tests index 86c46ad..eeeef28 100755 --- a/run_tests +++ b/run_tests @@ -12,6 +12,7 @@ export BOXES="" export FILES="" +export KEEP_RUNNING="" # global variable for script exit value export EXIT_VALUE=0 @@ -22,6 +23,7 @@ display_help() { echo " ./run_tests -m ubuntu # runs tests on ubuntu VM" echo " ./run_tests -m ubuntu -m centos # runs tests on ubuntu and cents VMs" echo " ./run_tests tests/some_test # run a single test file" + echo " ./run_tests --keep-running # don't stop vagrant after the tests are done" } parse_arguments() { @@ -41,6 +43,11 @@ parse_arguments() { shift 2 ;; + -k | --keep-running) + KEEP_RUNNING="true" + shift + ;; + -h | --help) display_help exit 0 @@ -81,15 +88,15 @@ run_vagrant() { VAGRANT_CWD=lib/tmux-test/ vagrant up "$box" } -# Halt vagrant after tests are done running, unless KEEP_RUNNING environment -# variable is set to 'true'. +# Halt vagrant after tests are done running, unless `--keep-running` +# option is given stop_vagrant() { local box="$1" if [ -z "$KEEP_RUNNING" ]; then VAGRANT_CWD=lib/tmux-test/ vagrant halt "$box" else echo - echo "KEEP_RUNNING is set. Vagrant not halted." + echo "--keep-running option set, Vagrant not halted" fi }