Skip to content

Commit

Permalink
Fix up scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Nov 2, 2017
1 parent 6b06012 commit 2ad6c9e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
2 changes: 2 additions & 0 deletions bin/is-executable
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

if type "$1" >/dev/null 2>&1; then
exit 0
else
Expand Down
2 changes: 2 additions & 0 deletions bin/is-macos
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

if [[ "$OSTYPE" =~ ^darwin ]]; then
exit 0
else
Expand Down
2 changes: 2 additions & 0 deletions bin/is-supported
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

if [ $# -eq 1 ]; then
if eval "$1" > /dev/null 2>&1; then
exit 0
Expand Down
20 changes: 20 additions & 0 deletions test/bin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@
[ "$ACTUAL" = "$EXPECTED" ]
}

@test "is-executable" {
run is-executable ls
[ "$status" -eq 0 ]
}

@test "is-executable (false)" {
run is-executable nonexistent
[ "$status" -eq 1 ]
}

@test "is-supported" {
run is-supported ls -a
[ "$status" -eq 0 ]
}

@test "is-supported (false)" {
run is-supported "ls --nonexistent"
[ "$status" -eq 1 ]
}

@test "set-config" {
run set-config KEY_A VALUE_1 MYFILE
run set-config KEY_B VALUE_2 MYFILE
Expand Down
20 changes: 0 additions & 20 deletions test/function.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@ FIXTURE_TEXT="foo"
[ "$ACTUAL" = "$EXPECTED" ]
}

@test "is-executable" {
run is-executable ls
[ "$status" -eq 0 ]
}

@test "is-executable (false)" {
run is-executable nonexistent
[ "$status" -eq 1 ]
}

@test "is-supported" {
run is-supported ls -a
[ "$status" -eq 0 ]
}

@test "is-supported (false)" {
run is-supported "ls --nonexistent"
[ "$status" -eq 1 ]
}

@test "calc" {
ACTUAL="$(calc 1+2)"
EXPECTED=3
Expand Down

0 comments on commit 2ad6c9e

Please sign in to comment.