Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

Commit 6ea0e8c

Browse files
committed
Make loose work as expected; fix test introduced with eficode/pull/11
1 parent 8718f5c commit 6ea0e8c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

wait-for

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fi
115115
for SERVICE in ${SERVICES}; do
116116
HOST=$(printf "%s\n" "$SERVICE" | cut -d : -f 1)
117117
PORT=$(printf "%s\n" "$SERVICE" | cut -d : -f 2)
118-
SUCCESS=1
118+
FAILURE=0
119119

120120
if [ "$HOST" = "" ] || [ "$PORT" = "" ]; then
121121
echoerr "Error: you need to provide a host and port to test."
@@ -124,14 +124,14 @@ for SERVICE in ${SERVICES}; do
124124

125125
wait_for
126126
if [ $? -eq 1 ]; then
127-
SUCCESS=0
127+
FAILURE=1
128128
fi
129129
done
130130

131-
if [ $SUCCESS -eq 1 ]; then
131+
if [ $FAILURE -eq 0 ] || [ $LOOSE -eq 1 ]; then
132132
if [ $# -gt 0 ]; then
133133
exec "$@"
134134
fi
135-
else
136-
exit 1
137135
fi
136+
137+
exit $FAILURE

wait-for.bats

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@test "google should be immediately found, no output other than our own" {
44
run ./wait-for -q google.com:80 -- echo 'success'
55

6+
[ "$status" -eq 0 ]
67
[ "$output" = "success" ]
78
}
89

@@ -14,9 +15,10 @@
1415
}
1516

1617
@test "google and bing should be immediately found" {
17-
run ./wait-for google.com:80 bing.com:80 -- echo 'success'
18+
run ./wait-for -q google.com:80 bing.com:80 -- echo 'success'
1819

19-
[ "$output" = "success" ]
20+
[ "$status" -eq 0 ]
21+
[ "$output" = "success" ]
2022
}
2123

2224
@test "nonexistent server should start command if loose option is specified" {

0 commit comments

Comments
 (0)