Skip to content

Commit

Permalink
Removing variable expansion flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nextrevision committed Aug 6, 2015
1 parent 1bd023f commit e31f442
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 32 deletions.
23 changes: 0 additions & 23 deletions shrift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ function _usage() {
echo "usage: $0 [args] specfiles..."
echo
echo "-h Help"
echo "-f [vars_file] Variables file to source before expanding (implies -e)"
echo "-d [container] Target running docker container"
echo "-s [hostname] Target remote host via ssh"
echo "-o '[opts]' Raw CLI options to pass to SSH/Docker (must be in quotes)"
echo "-e Expand variables in spec before running"
echo "-v Enable verbose output"
echo
}
Expand Down Expand Up @@ -51,16 +49,9 @@ function _print_dot() {
fi
}

function _expand_vars() {
local tmp=$(_mktemp)
eval "echo \"$(cat $1)\"" > $tmp
echo $tmp
}

function _run_file() {
local file=$1
[ $verbose -eq 1 ] && echo "# ${1}"
[ $expand_vars -eq 1 ] && file=$(_expand_vars $1)
# loop through specs
while read spec; do
# skip comments
Expand Down Expand Up @@ -92,26 +83,21 @@ function _run_file() {
fi
result_summary+=$(_print_dot $cmd_rc)
done < $file
[ $expand_vars -eq 1 ] && rm $file
}

function _main() {
driver='local'
opts=''
vars_file=''
expand_vars=0
verbose=0
spec_files=()

# parse cli args
while [ ! -z $1 ]; do
case $1 in
-h|--help) _usage; exit 0;;
-f) shift; vars_file=$1; expand_vars=1;;
-d) shift; driver='docker'; target=$1;;
-s) shift; driver='ssh'; target=$1;;
-o) shift; opts="${1}";;
-e) expand_vars=1;;
-v) verbose=1;;
*) spec_files+=("$1");;
esac
Expand All @@ -134,15 +120,6 @@ function _main() {
fi
fi

# source variable file
if [ ! -z $vars_file ]; then
if [ ! -f $vars_file ]; then
_error "No such vars_file ${vars_file}"
else
source ${vars_file}
fi
fi

# global run state
total_specs=0
failed_specs=0
Expand Down
7 changes: 0 additions & 7 deletions shrift_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ assert "_print_dot 0" "${GREEN}.${END}"
assert "_print_dot 1" "${RED}F${END}"
assert "_print_dot 255" "${RED}F${END}"

# test _expand_vars
t=$(_expand_vars test/fixtures/vars_test)
assert_raises "test -f ${t}"
assert "cat ${t}" "echo ${USER}"
rm $t

# test _main output
assert "_main test/fixtures/pass_spec.sh" "\n${GREEN}.${END}${GREEN}.${END}\n2 tests, 0 failed"
assert "_main test/fixtures/fail_spec.sh" "${RED}Failure 1${END}: test -f notpresent\n\n${RED}F${END}\n1 tests, 1 failed"
Expand All @@ -54,7 +48,6 @@ assert_raises "./shrift -h | grep -q 'usage: '" 0
assert "./shrift test/fixtures/pass_spec.sh" "\n${GREEN}.${END}${GREEN}.${END}\n2 tests, 0 failed\n"
assert "./shrift test/fixtures/fail_spec.sh" "${RED}Failure 1${END}: test -f notpresent\n\n${RED}F${END}\n1 tests, 1 failed\n"
assert "./shrift -v test/fixtures/pass_spec.sh" "# test/fixtures/pass_spec.sh\n${GREEN}Success 0${END}: test -f ./shrift\n${GREEN}Success 0${END}: test -f ./shrift_test.sh\n\n${GREEN}.${END}${GREEN}.${END}\n2 tests, 0 failed\n"
assert "./shrift -v -f test/fixtures/vars_file test/fixtures/vars_test" "# test/fixtures/vars_test\n${GREEN}Success 0${END}: echo notarealuser\n notarealuser\n\n${GREEN}.${END}\n1 tests, 0 failed"

# test runtime return code
assert_raises "./shrift test/fixtures/pass_spec.sh" 0
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/vars_file

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/vars_test

This file was deleted.

0 comments on commit e31f442

Please sign in to comment.