You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

4 years ago
  1. #!/bin/sh
  2. pecho() { printf %s\\n "$*"; }
  3. log() { pecho "$@"; }
  4. error() { log "ERROR: $@" >&2; }
  5. fatal() { error "$@"; exit 1; }
  6. try() { "$@" || fatal "'$@' failed"; }
  7. MY_DIR=$(try cd "${0%/*}" && try pwd) || fatal "failed to find script directory"
  8. # reliably move to the etherpad base folder before running it
  9. try cd "${MY_DIR}/../../../"
  10. try sed -e '
  11. s!"soffice":[^,]*!"soffice": "/usr/bin/soffice"!
  12. # Reduce rate limit aggressiveness
  13. s!"max":[^,]*!"max": 100!
  14. s!"points":[^,]*!"points": 1000!
  15. # GitHub does not like our output
  16. s!"loglevel":[^,]*!"loglevel": "WARN"!
  17. ' settings.json.template >settings.json
  18. log "Assuming bin/installDeps.sh has already been run"
  19. node node_modules/ep_etherpad-lite/node/server.js "${@}" &
  20. ep_pid=$!
  21. log "Waiting for Etherpad to accept connections (http://localhost:9001)..."
  22. connected=false
  23. can_connect() {
  24. curl -sSfo /dev/null http://localhost:9001/ || return 1
  25. connected=true
  26. }
  27. now() { date +%s; }
  28. start=$(now)
  29. while [ $(($(now) - $start)) -le 15 ] && ! can_connect; do
  30. sleep 1
  31. done
  32. [ "$connected" = true ] \
  33. || fatal "Timed out waiting for Etherpad to accept connections"
  34. log "Successfully connected to Etherpad on http://localhost:9001"
  35. log "Running the backend tests..."
  36. try cd src
  37. npm test
  38. exit_code=$?
  39. kill "$ep_pid" && wait "$ep_pid"
  40. log "Done."
  41. exit "$exit_code"