Skip to content

Commit

Permalink
Add '--keep-running' cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Sutic committed Aug 3, 2015
1 parent e5e2504 commit e1b299b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
13 changes: 10 additions & 3 deletions run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

export BOXES=""
export FILES=""
export KEEP_RUNNING=""

# global variable for script exit value
export EXIT_VALUE=0
Expand All @@ -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() {
Expand All @@ -41,6 +43,11 @@ parse_arguments() {
shift 2
;;

-k | --keep-running)
KEEP_RUNNING="true"
shift
;;

-h | --help)
display_help
exit 0
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit e1b299b

Please sign in to comment.