From 3bb486e4397415e1855e5edbf28d8e50c3d45265 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 10 Feb 2014 09:39:48 -0500 Subject: [PATCH] tests: auto-set LIB_HTTPD_PORT from test name We set the default apache port for each of the httpd tests to the 4-digit test number of the test script. We want these to remain unique so that the tests do not conflict with each other when run in parallel. Instead of doing it manually in each test script, let's just set it from the test name at run time. This is simpler, and is one less thing to be updated when test scripts are renamed (e.g., when being re-rolled or when conflicting after being merged with another topic). Incidentally, this fixes a case where t5537 and t5538 used the same port number (5537), and could conflict with each other when run in parallel. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/lib-httpd.sh | 2 +- t/t5537-fetch-shallow.sh | 1 - t/t5538-push-shallow.sh | 1 - t/t5540-http-push.sh | 1 - t/t5541-http-push.sh | 1 - t/t5550-http-fetch.sh | 1 - t/t5551-http-fetch.sh | 1 - t/t5561-http-backend.sh | 1 - 8 files changed, 1 insertion(+), 8 deletions(-) diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index bfdff2a8c9..b43162ea2a 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -64,7 +64,7 @@ case $(uname) in esac LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"} -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'8111'} +LIB_HTTPD_PORT=${LIB_HTTPD_PORT-${this_test#t}} TEST_PATH="$TEST_DIRECTORY"/lib-httpd HTTPD_ROOT_PATH="$PWD"/httpd diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh index b0fa7387cb..adf215a193 100755 --- a/t/t5537-fetch-shallow.sh +++ b/t/t5537-fetch-shallow.sh @@ -178,7 +178,6 @@ if test -n "$NO_CURL" -o -z "$GIT_TEST_HTTPD"; then test_done fi -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5537'} . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5538-push-shallow.sh b/t/t5538-push-shallow.sh index 0a6e40f144..8e54ac5746 100755 --- a/t/t5538-push-shallow.sh +++ b/t/t5538-push-shallow.sh @@ -126,7 +126,6 @@ if test -n "$NO_CURL" -o -z "$GIT_TEST_HTTPD"; then test_done fi -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5537'} . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh index 5b0198cbc8..8d7b3c57e3 100755 --- a/t/t5540-http-push.sh +++ b/t/t5540-http-push.sh @@ -16,7 +16,6 @@ then fi LIB_HTTPD_DAV=t -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'} . "$TEST_DIRECTORY"/lib-httpd.sh ROOT_PATH="$PWD" start_httpd diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh index bfd241ea8a..73af16f481 100755 --- a/t/t5541-http-push.sh +++ b/t/t5541-http-push.sh @@ -12,7 +12,6 @@ if test -n "$NO_CURL"; then fi ROOT_PATH="$PWD" -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5541'} . "$TEST_DIRECTORY"/lib-httpd.sh . "$TEST_DIRECTORY"/lib-terminal.sh start_httpd diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh index 8392624714..1a3a2b6c1a 100755 --- a/t/t5550-http-fetch.sh +++ b/t/t5550-http-fetch.sh @@ -8,7 +8,6 @@ if test -n "$NO_CURL"; then test_done fi -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5550'} . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh index a124efe114..e07eaf35f1 100755 --- a/t/t5551-http-fetch.sh +++ b/t/t5551-http-fetch.sh @@ -8,7 +8,6 @@ if test -n "$NO_CURL"; then test_done fi -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5551'} . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh index b5d7fbc381..d23fb02384 100755 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@ -8,7 +8,6 @@ if test -n "$NO_CURL"; then test_done fi -LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5561'} . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd -- 2.11.4.GIT