diff --git a/.travis.yml b/.travis.yml index 392b52e..e8a4731 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,8 @@ services: before_install: - docker build -t eficode/wait-for . + +script: + - npm install + - ./run_tests.sh - docker run eficode/wait-for diff --git a/Dockerfile b/Dockerfile index 412d8e1..f636844 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,5 @@ WORKDIR /app COPY . /app RUN npm install -CMD ./node_modules/.bin/bats wait-for.bats +# On launch, run the test suite via npm +CMD npm test diff --git a/package.json b/package.json index 977ac4a..7aea0e7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "wait-for", "version": "0.1.0", "scripts": { - "test": "./node_modules/.bin/bats wait-for.bats" + "test": "./run_tests.sh" }, "dependencies": { "bats": "^0.4.2" diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..13bf63a --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Although it would be possible to just call this directly from the Dockerfile, +# centralizing tests in this file allows both the docker container and the +# CI machine to run the same set of tests for an additional datapoint -- +# which gives a better chance of turning up POSIX noncompliance + +./node_modules/.bin/bats wait-for.bats \ No newline at end of file diff --git a/wait-for b/wait-for index d6b04d8..a553daf 100755 --- a/wait-for +++ b/wait-for @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash OLD_TIMEOUT=$TIMEOUT OLD_QUIET=$QUIET @@ -34,7 +34,7 @@ USAGE test_connection() { # force a 1-second timeout on darwin (https://stackoverflow.com/a/20460402/2063546) - if [ -z "${$OSTYPE##*darwin*}" ] ; then + if [ -z "${OSTYPE##*darwin*}" ] ; then nc -w 1 -G 1 "$1" "$2" > /dev/null 2>&1 else nc -w 1 "$1" "$2" > /dev/null 2>&1