From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tarmigan Casebolt Subject: [PATCH v4 3/3] Smart-http tests: Test http-backend without curl or a webserver Date: Sat, 2 Jan 2010 13:43:59 -0800 Message-ID: <1262468639-8847-1-git-send-email-tarmigan+git@gmail.com> References: <20100102214107.GO6914@spearce.org> Cc: "Shawn O. Pearce" , git@vger.kernel.org, Tarmigan Casebolt To: Junio C Hamano X-From: git-owner@vger.kernel.org Sat Jan 02 22:44:52 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.50) id 1NRBlg-0002wF-7s for gcvg-git-2@lo.gmane.org; Sat, 02 Jan 2010 22:44:16 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751702Ab0ABVoK (ORCPT ); Sat, 2 Jan 2010 16:44:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751800Ab0ABVoK (ORCPT ); Sat, 2 Jan 2010 16:44:10 -0500 Received: from mail-yw0-f176.google.com ([209.85.211.176]:64573 "EHLO mail-yw0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751162Ab0ABVoI (ORCPT ); Sat, 2 Jan 2010 16:44:08 -0500 Received: by ywh6 with SMTP id 6so14247345ywh.4 for ; Sat, 02 Jan 2010 13:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=q27StXnAW+zxHxsrSt3m9gQFLYPl46t1l4Fn0hRvHdU=; b=rATdRChlvaBM5GkoSCA9eQ72wPv/cG9p4O14Q2VnMB66h5Yj+01aN60NiYoLS1JO06 ATTP/KvmE8alucP5yFa5BCjWfbLLbvXuSD+Z24r9hVSANRBl4GeJnLwFAsOxvx2u0dbT e0FXTDct8ic3LGrMPc+yq3gvzHBhO4m1wh/J8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=MTgXFZ2Fha+4v45c/CbetaW+gwRRS7c0YJEgXSujCJhAqUzYi+dxOUIdDLZnpPJZLj Fip8EHt42VH8+KdBEOUzPNbMTuPmZejC8KjfxbkXRnuqrROSyc5XeQy8y1k7osviwZDk ZoLzh/UK5sFA5FBtHopQyjHC1oEL6J+d0pMp8= Received: by 10.150.44.27 with SMTP id r27mr4571373ybr.263.1262468647086; Sat, 02 Jan 2010 13:44:07 -0800 (PST) Received: from localhost.localdomain (c-69-181-44-199.hsd1.ca.comcast.net [69.181.44.199]) by mx.google.com with ESMTPS id 5sm6534053yxg.28.2010.01.02.13.44.05 (version=SSLv3 cipher=RC4-MD5); Sat, 02 Jan 2010 13:44:06 -0800 (PST) X-Mailer: git-send-email 1.6.6.236.gc56f3 In-Reply-To: <20100102214107.GO6914@spearce.org> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: This reuses many of the tests from the old t5560 but runs those tests without curl or a webserver. This will hopefully increase the testing coverage for http-backend because it does not require users to set GIT_TEST_HTTPD. Signed-off-by: Tarmigan Casebolt --- Oops forgot to commit the grep changes. Only resending 3/3 of the series. --- t/t5560-http-backend-noserver.sh | 26 ++++++++++++++++++++------ t/t556x_common | 3 +++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh index a9ba2d9..a63d3ec 100755 --- a/t/t5560-http-backend-noserver.sh +++ b/t/t5560-http-backend-noserver.sh @@ -6,18 +6,32 @@ test_description='test git-http-backend-noserver' HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY" run_backend() { - REQUEST_METHOD=GET \ + echo "$2"| \ + QUERY_STRING="${1#*\?}" \ GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \ - PATH_INFO="$1" \ + PATH_INFO="${1%%\?*}" \ git http-backend >act.out 2>act.err } GET() { - return 0 + REQUEST_METHOD="GET" \ + run_backend "/repo.git/$1" && + if ! grep "Status" act.out >act; then + printf "Status: 200 OK\r\n" > act + fi + printf "Status: $2\r\n" > exp && + test_cmp exp act } POST() { - return 0 + REQUEST_METHOD="POST" \ + CONTENT_TYPE="application/x-$1-request" \ + run_backend "/repo.git/$1" "$2" && + if ! grep "Status" act.out >act; then + printf "Status: 200 OK\r\n" > act + fi + printf "Status: $3\r\n" > exp && + test_cmp exp act } log_div() { @@ -28,9 +42,9 @@ log_div() { expect_aliased() { if test $1 = 0; then - run_backend "$2" + REQUEST_METHOD=GET run_backend "$2" else - run_backend "$2" && + REQUEST_METHOD=GET run_backend "$2" && echo "fatal: '$2': aliased" >exp.err && test_cmp exp.err act.err fi diff --git a/t/t556x_common b/t/t556x_common index 1b4921c..be024e5 100755 --- a/t/t556x_common +++ b/t/t556x_common @@ -50,6 +50,7 @@ get_static_files() { } SMART=smart +export GIT_HTTP_EXPORT_ALL=1 test_expect_success 'direct refs/heads/master not found' ' log_div "refs/heads/master" GET refs/heads/master "404 Not Found" @@ -59,6 +60,7 @@ test_expect_success 'static file is ok' ' get_static_files "200 OK" ' SMART=smart_noexport +unset GIT_HTTP_EXPORT_ALL test_expect_success 'no export by default' ' log_div "no git-daemon-export-ok" get_static_files "404 Not Found" @@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' ' get_static_files "200 OK" ' SMART=smart +export GIT_HTTP_EXPORT_ALL=1 test_expect_success 'static file if http.getanyfile true is ok' ' log_div "getanyfile true" config http.getanyfile true && -- 1.6.6.236.gc56f3