From da706545f7a1fa97cd8d9cf40659ab2a167be7c0 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 13 Mar 2015 00:48:48 -0400 Subject: t: translate SIGINT to an exit Right now if a test script receives SIGINT (e.g., because a test was hanging and the user hit ^C), the shell exits immediately. This can be annoying if the test script did any global setup, like starting apache or git-daemon, as it will not have an opportunity to clean up after itself. A subsequent run of the test won't be able to start its own daemon, and will either fail or skip the tests. Instead, let's trap SIGINT to make sure we do a clean shutdown, and just chain it to a normal exit (which will trigger any cleanup). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/test-lib.sh | 1 + 1 file changed, 1 insertion(+) (limited to 't') diff --git a/t/test-lib.sh b/t/test-lib.sh index c09677802c..f4ba3ff972 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -299,6 +299,7 @@ die () { GIT_EXIT_OK= trap 'die' EXIT +trap 'exit $?' INT # The user-facing functions are loaded from a separate file so that # test_perf subshells can have them too -- cgit v1.2.3 From 025232e8aa4b56d450079528fcfbff53da3e7fa4 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 13 Mar 2015 00:50:56 -0400 Subject: t: redirect stderr GIT_TRACE to descriptor 4 If you run a test script like: GIT_TRACE=1 ./t0061-run-command.sh you may get test failures, because some tests capture and check the stderr output from git commands (and with GIT_TRACE set to 1, the trace output will be included there). When we see GIT_TRACE set like this, we print a warning to the user. However, we can do even better than that by just pointing it to descriptor 4, which all tests leave connected to the test script's stderr. That's likely what the user intended (and any scripts that do want to see GIT_TRACE output will set GIT_TRACE themselves). Not only does this avoid false negatives in the tests, but it means the user will actually see trace output for git calls that redirect their stderr (whereas before, it was sometimes confusingly buried in a file). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/test-lib.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 't') diff --git a/t/test-lib.sh b/t/test-lib.sh index f4ba3ff972..7dd4b4d1c2 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -152,10 +152,7 @@ unset UNZIP case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in 1|2|true) - echo "* warning: Some tests will not work if GIT_TRACE" \ - "is set as to trace on STDERR ! *" - echo "* warning: Please set GIT_TRACE to something" \ - "other than 1, 2 or true ! *" + GIT_TRACE=4 ;; esac -- cgit v1.2.3 From 89c57ab3f0168b192d5ccc159972fdb26e0ba80b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 13 Mar 2015 00:51:15 -0400 Subject: t: pass GIT_TRACE through Apache Apache removes GIT_TRACE from the environment before running git-http-backend. This can make it hard to debug the server side of an http session. Let's let it through. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/lib-httpd.sh | 1 + t/lib-httpd/apache.conf | 1 + 2 files changed, 2 insertions(+) (limited to 't') diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index d154d1ed1d..e6adf2f82d 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -79,6 +79,7 @@ HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www # hack to suppress apache PassEnv warnings GIT_VALGRIND=$GIT_VALGRIND; export GIT_VALGRIND GIT_VALGRIND_OPTIONS=$GIT_VALGRIND_OPTIONS; export GIT_VALGRIND_OPTIONS +GIT_TRACE=$GIT_TRACE; export GIT_TRACE if ! test -x "$LIB_HTTPD_PATH" then diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf index 03a4c2ee84..0b81a0047b 100644 --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@ -70,6 +70,7 @@ PassEnv GIT_VALGRIND PassEnv GIT_VALGRIND_OPTIONS PassEnv GNUPGHOME PassEnv ASAN_OPTIONS +PassEnv GIT_TRACE Alias /dumb/ www/ Alias /auth/dumb/ www/auth/dumb/ -- cgit v1.2.3 From 9a308de37c485068d6470d4c51e231a36e651e98 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 13 Mar 2015 00:53:07 -0400 Subject: t5541: move run_with_cmdline_limit to test-lib.sh We use this to test http pushing with a restricted commandline. Other scripts (like t5551, which does http fetching) will want to use it, too. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t5541-http-push-smart.sh | 6 ------ t/test-lib.sh | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 't') diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index d2c681ebfd..1ecb5881ac 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -324,12 +324,6 @@ test_expect_success 'push into half-auth-complete requires password' ' test_cmp expect actual ' -run_with_limited_cmdline () { - (ulimit -s 128 && "$@") -} - -test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true' - test_expect_success CMDLINE_LIMIT 'push 2000 tags over http' ' sha1=$(git rev-parse HEAD) && test_seq 2000 | diff --git a/t/test-lib.sh b/t/test-lib.sh index 7dd4b4d1c2..9914d3e1cf 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1062,3 +1062,9 @@ test_lazy_prereq UNZIP ' "$GIT_UNZIP" -v test $? -ne 127 ' + +run_with_limited_cmdline () { + (ulimit -s 128 && "$@") +} + +test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true' -- cgit v1.2.3 From 376e4b39d4453ce50cbacc9c46a3bbdaad2134b2 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 13 Mar 2015 00:57:05 -0400 Subject: t5551: make EXPENSIVE test cheaper We create 50,000 tags to check that we don't overflow the command-line of fetch-pack. But by using run_with_cmdline_limit, we can get the same effect with a much smaller number of tags. This makes the test fast enough that we can drop the EXPENSIVE prereq, which means people will actually run it. It was not documented to do so, but this test was also the only test of a clone-over-http that requires multiple POSTs during the conversation. We can continue to test that by dropping http.postbuffer to its minimum size, and checking that we get two POSTs. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t5551-http-fetch-smart.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 't') diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index 6cbc12d9a7..7f6eb9f3db 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -213,10 +213,10 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set test_cmp expect_cookies.txt cookies_tail.txt ' -test_expect_success EXPENSIVE 'create 50,000 tags in the repo' ' +test_expect_success 'create 2,000 tags in the repo' ' ( cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - for i in `test_seq 50000` + for i in $(test_seq 2000) do echo "commit refs/heads/too-many-refs" echo "mark :$i" @@ -237,13 +237,22 @@ test_expect_success EXPENSIVE 'create 50,000 tags in the repo' ' ) ' -test_expect_success EXPENSIVE 'clone the 50,000 tag repo to check OS command line overflow' ' - git clone $HTTPD_URL/smart/repo.git too-many-refs && +test_expect_success CMDLINE_LIMIT \ + 'clone the 2,000 tag repo to check OS command line overflow' ' + run_with_limited_cmdline git clone $HTTPD_URL/smart/repo.git too-many-refs && ( cd too-many-refs && - test $(git for-each-ref refs/tags | wc -l) = 50000 + git for-each-ref refs/tags >actual && + test_line_count = 2000 actual ) ' +test_expect_success 'large fetch-pack requests can be split across POSTs' ' + GIT_CURL_VERBOSE=1 git -c http.postbuffer=65536 \ + clone --bare "$HTTPD_URL/smart/repo.git" split.git 2>err && + grep "^> POST" err >posts && + test_line_count = 2 posts +' + stop_httpd test_done -- cgit v1.2.3