Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptt-homme committed Aug 31, 2020
1 parent 29c7647 commit 2d2f83e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions .hastest.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ teardown() {
run $has

[ "$status" -eq 0 ]
[ "${lines[0]%% *}" = 'has' ]
[ "${lines[1]%%:*}" = 'USAGE' ]
[ "${lines[2]}" = 'EXAMPLE: has git curl node' ]
[ "${lines[0]}" = 'Usage: has [OPTION] <command-names>...' ]
[ "${lines[1]}" = 'Has checks the presence of various command line tools on the PATH and reports their installed version.' ]
[ "${lines[2]}" = 'Options:' ]
[ "${lines[3]}" = ' -q Silent mode' ]
[ "${lines[4]}" = ' -h, --help Display this help text and quit' ]
[ "${lines[5]}" = ' -V, --version Show version number and quit' ]
[ "${lines[6]}" = 'Examples: has git curl node' ]
}

@test "make install creates a valid installation" {
Expand All @@ -38,11 +42,15 @@ teardown() {
# has reads .hasrc from $PWD, so change anywhere else.
cd "${INSTALL_DIR}"
run "${INSTALL_DIR}/bin/has"

[ "$status" -eq 0 ]
[ "${lines[0]%% *}" = 'has' ]
[ "${lines[1]%%:*}" = 'USAGE' ]
[ "${lines[2]}" = 'EXAMPLE: has git curl node' ]
# [ "${lines[2]%%:*}" = 'EXAMPLE' ]
[ "${lines[0]}" = 'Usage: has [OPTION] <command-names>...' ]
[ "${lines[1]}" = 'Has checks the presence of various command line tools on the PATH and reports their installed version.' ]
[ "${lines[2]}" = 'Options:' ]
[ "${lines[3]}" = ' -q Silent mode' ]
[ "${lines[4]}" = ' -h, --help Display this help text and quit' ]
[ "${lines[5]}" = ' -V, --version Show version number and quit' ]
[ "${lines[6]}" = 'Examples: has git curl node' ]
}

@test "..even if 'has' is missing from directory" {
Expand Down Expand Up @@ -189,7 +197,8 @@ teardown() {
}

@test "quiet mode" {
run $has -q
run $has -q git

[ "$status" -eq 0 ]
[ -z "${output}" ]
}
Expand Down
2 changes: 1 addition & 1 deletion has
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ fi

# if HASRC is not set AND no arguments passed to script
if [[ -z "${HASRC}" ]] && [ "$#" -eq 0 ]; then
_usage
echo ''
else
# for each cli-arg
for cmd in "$@"; do
Expand Down

0 comments on commit 2d2f83e

Please sign in to comment.