123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #!/usr/bin/env bash
- # How to run:
- #
- # ./bootandkill-servers ./test-acceptance
- #
- # this will boot hexo & uppy-server, run the acceptance tests,
- # and tear down the servers.
- #
- # To run just the acceptance tests:
- #
- # ./test-acceptance
- #
- set -o pipefail
- set -o errexit
- set -o nounset
- # set -o xtrace
- # Set magic variables for current file & dir
- __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
- __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
- __base="$(basename ${__file} .sh)"
- __root="$(cd "$(dirname "${__dir}")" && pwd)"
- function waitForPortOpen () {
- local port="${1}"
- local limit="${2:-60}"
- local attempts=0
- echo "[${__base}] waiting on port ${port} to open... "
- while ! echo exit | nc localhost ${port}; do
- let "attempts = attempts + 1"
- echo "[${__base}] still waiting on port ${port} to open... (${attempts} / ${limit}) "
- sleep 1
- if [ "${attempts}" -ge "${limit}" ]; then
- echo "[${__base}] --> Port did not open for ${limit} seconds. Aborting. "
- exit 1
- fi
- done
- }
- echo "[${__base}] --> Wait for hexo webserver to be online"
- waitForPortOpen 4000
- echo "[${__base}] --> Wait for uppy-server to be online"
- waitForPortOpen 8080
- echo "[${__base}] --> Sleeping 20s, because the port may be open, but Hexo may still be injecting/building stuff"
- echo "[${__base}] --> and I don't know yet how to check for that"
- sleep 20
- echo "[${__base}] --> Running acceptance tests"
- node test/multipart.spec.js
|