From 16750d024ce038b019ab2e9ee5639901e445af37 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Fri, 26 Aug 2022 18:28:44 -0400 Subject: [PATCH] t/lib-git-daemon: try harder to find a port As with the previous commit, try harder to find an open port to avoid intermittent failures on busy/shared build systems. By default, we make 3 attempts. This may be overridden by setting GIT_TEST_START_GIT_DAEMON_TRIES to a different value. Signed-off-by: Todd Zullinger --- t/lib-git-daemon.sh | 60 ++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh index e62569222b..c3e8dda9ff 100644 --- a/t/lib-git-daemon.sh +++ b/t/lib-git-daemon.sh @@ -51,30 +51,44 @@ start_git_daemon() { registered_stop_git_daemon_atexit_handler=AlreadyDone fi - say >&3 "Starting git daemon ..." - mkfifo git_daemon_output - ${LIB_GIT_DAEMON_COMMAND:-git daemon} \ - --listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \ - --reuseaddr --verbose --pid-file="$GIT_DAEMON_PIDFILE" \ - --base-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH" \ - "$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \ - >&3 2>git_daemon_output & - GIT_DAEMON_PID=$! - { - read -r line <&7 - printf "%s\n" "$line" >&4 - cat <&7 >&4 & - } 7&3 "Starting git daemon on port $LIB_GIT_DAEMON_PORT ..." + mkfifo git_daemon_output + ${LIB_GIT_DAEMON_COMMAND:-git daemon} \ + --listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \ + --reuseaddr --verbose --pid-file="$GIT_DAEMON_PIDFILE" \ + --base-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH" \ + "$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \ + >&3 2>git_daemon_output & + GIT_DAEMON_PID=$! + { + read -r line <&7 + printf "%s\n" "$line" >&4 + cat <&7 >&4 & + } 7