From 22246b648b730e7bb4bd13e016d13a303b4a4fd3 Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Thu, 12 May 2022 16:43:33 -0500 Subject: [PATCH] Tests: Wait for nginx to create pid file When nginx is started, it returns control before it has created its pid file. Since this test suite relies on the existence of the pid file, wait until the pid file exists before returning from nginx_start. Time out after 2 seconds so that if there is a real problem starting nginx we don't wait forever. Fixes #144 --- t/preamble | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/preamble b/t/preamble index 354b2b3..c55e13c 100644 --- a/t/preamble +++ b/t/preamble @@ -90,6 +90,11 @@ function nginx_start () { if [[ $# -gt 0 || ! -r ${NGINX_CONF} ]] ; then nginx_conf "$@" ; fi nginx_stop # Ensure that it is not running. nginx + local n=0 + while [[ ! -r ${NGINX_PID} && n -lt 20 ]] ; do + sleep 0.1 # Wait until pid exists. + n=$((n+1)) + done } function fetch () {