2020-11-21 00:19:39 +00:00
|
|
|
#!/bin/sh
|
2020-04-03 01:27:05 +00:00
|
|
|
|
2020-11-21 00:19:39 +00:00
|
|
|
pecho() { printf %s\\n "$*"; }
|
|
|
|
log() { pecho "$@"; }
|
|
|
|
error() { log "ERROR: $@" >&2; }
|
|
|
|
fatal() { error "$@"; exit 1; }
|
|
|
|
try() { "$@" || fatal "'$@' failed"; }
|
2020-04-03 01:27:05 +00:00
|
|
|
|
2020-11-21 00:19:39 +00:00
|
|
|
MY_DIR=$(try cd "${0%/*}" && try pwd) || fatal "failed to find script directory"
|
2020-04-03 01:27:05 +00:00
|
|
|
|
|
|
|
# reliably move to the etherpad base folder before running it
|
2020-11-21 00:19:39 +00:00
|
|
|
try cd "${MY_DIR}/../../../"
|
2020-04-03 01:27:05 +00:00
|
|
|
|
2020-11-21 00:19:39 +00:00
|
|
|
try sed -e '
|
|
|
|
s!"soffice":[^,]*!"soffice": "/usr/bin/soffice"!
|
|
|
|
# Reduce rate limit aggressiveness
|
|
|
|
s!"max":[^,]*!"max": 100!
|
|
|
|
s!"points":[^,]*!"points": 1000!
|
2020-11-25 07:20:50 +00:00
|
|
|
# GitHub does not like our output
|
|
|
|
s!"loglevel":[^,]*!"loglevel": "WARN"!
|
2020-11-21 00:19:39 +00:00
|
|
|
' settings.json.template >settings.json
|
2020-07-16 09:46:45 +00:00
|
|
|
|
2020-11-21 00:19:39 +00:00
|
|
|
log "Assuming bin/installDeps.sh has already been run"
|
2020-11-21 02:04:54 +00:00
|
|
|
node node_modules/ep_etherpad-lite/node/server.js "${@}" &
|
2020-11-21 02:11:21 +00:00
|
|
|
ep_pid=$!
|
2020-04-03 01:27:05 +00:00
|
|
|
|
2020-11-21 00:19:39 +00:00
|
|
|
log "Waiting for Etherpad to accept connections (http://localhost:9001)..."
|
|
|
|
connected=false
|
|
|
|
can_connect() {
|
|
|
|
curl -sSfo /dev/null http://localhost:9001/ || return 1
|
|
|
|
connected=true
|
|
|
|
}
|
|
|
|
now() { date +%s; }
|
|
|
|
start=$(now)
|
|
|
|
while [ $(($(now) - $start)) -le 15 ] && ! can_connect; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
[ "$connected" = true ] \
|
|
|
|
|| fatal "Timed out waiting for Etherpad to accept connections"
|
|
|
|
log "Successfully connected to Etherpad on http://localhost:9001"
|
|
|
|
|
|
|
|
log "Running the backend tests..."
|
|
|
|
try cd src
|
|
|
|
npm test
|
|
|
|
exit_code=$?
|
2020-04-03 01:27:05 +00:00
|
|
|
|
2020-11-21 02:11:21 +00:00
|
|
|
kill "$ep_pid" && wait "$ep_pid"
|
2020-11-21 00:19:39 +00:00
|
|
|
log "Done."
|
|
|
|
exit "$exit_code"
|