kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/web/site/check_links_test.sh (about)

     1  #!/bin/bash
     2  set -e
     3  JEKYLL_BIN="$(realpath "$JEKYLL_BIN")"
     4  cd "kythe/web/site"
     5  "${JEKYLL_BIN}" serve --skip-initial-build --no-watch &
     6  server_pid=$!
     7  trap 'kill -INT "$server_pid"' EXIT ERR INT
     8  
     9  for ((i=0; i < 10; i++)); do
    10    if curl -s localhost:4000 >/dev/null; then
    11      break
    12    fi
    13    echo 'Waiting for server...' >&2
    14    sleep 1s
    15  done
    16  
    17  set -o pipefail
    18  wget --spider -nv -e robots=off -r -p http://localhost:4000 2>&1 | \
    19    grep -v -e 'unlink: ' -e ' URL:'
    20  
    21  # If grep finds a match, exit with a failure.
    22  if [[ "${PIPESTATUS[1]}" -ne 1 ]]; then
    23    exit 1
    24  fi