From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Grennan Subject: [PATCHv2-w 105/105] t6300 (for-each-ref): modernize style Date: Fri, 2 Mar 2012 18:15:42 -0800 Message-ID: <1330740942-25130-11-git-send-email-tmgrennan@gmail.com> References: <1330740942-25130-1-git-send-email-tmgrennan@gmail.com> Cc: Junio C Hamano , Jeff King , Carlos Rica , Andy Parkins , "Shawn O. Pearce" , Johannes Schindelin To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sat Mar 03 03:16:50 2012 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S3eWg-0001tn-13 for gcvg-git-2@plane.gmane.org; Sat, 03 Mar 2012 03:16:50 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751249Ab2CCCQp (ORCPT ); Fri, 2 Mar 2012 21:16:45 -0500 Received: from mail-vx0-f174.google.com ([209.85.220.174]:48188 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751023Ab2CCCQU (ORCPT ); Fri, 2 Mar 2012 21:16:20 -0500 Received: by mail-vx0-f174.google.com with SMTP id p1so2024061vcq.19 for ; Fri, 02 Mar 2012 18:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of tmgrennan@gmail.com designates 10.52.68.241 as permitted sender) client-ip=10.52.68.241; Authentication-Results: mr.google.com; spf=pass (google.com: domain of tmgrennan@gmail.com designates 10.52.68.241 as permitted sender) smtp.mail=tmgrennan@gmail.com; dkim=pass header.i=tmgrennan@gmail.com Received: from mr.google.com ([10.52.68.241]) by 10.52.68.241 with SMTP id z17mr20575115vdt.97.1330740980236 (num_hops = 1); Fri, 02 Mar 2012 18:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=HT4BNjwi0rlDd1xvGOf8+8L1SLVsyeouLtXahSjaSUE=; b=zxAzSg9ikuOU4IsIVrFwThRq9hBluG643qLaxqqjT6bLMblubhqJlUA/j8B7UFBNWi QUtvjXsrjc99g+dRMkfysn1eYQhn8L4Bz4AnKcFoDmD0rgH2vhhamHwuqsnqIW5coojH LDrXdwguXbcuKi89y0Uq4Vb6ggbjHFciHXg+uTRtv/79t1zTk6YX+kTk1hSOqwk0mUkn MX5+qXGPW8zlBPpQ5JSBiY81svgf7tyGiXqASm5I0XUolx3D4eOSxf2WMJ/ITj9fCdzP jQJ5roP5JJQKJWaHz8yGGN7Gk4cIop2s3t2ZzIqaTzivhF0Nx9zFil1CVwWjMovolnLF 1WKA== Received: by 10.52.68.241 with SMTP id z17mr17577336vdt.97.1330740980169; Fri, 02 Mar 2012 18:16:20 -0800 (PST) Received: from tgrennan-laptop.lab.redback.com ([129.192.185.163]) by mx.google.com with ESMTPS id e10sm11763981vdj.21.2012.03.02.18.16.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Mar 2012 18:16:19 -0800 (PST) X-Mailer: git-send-email 1.7.8 In-Reply-To: <1330740942-25130-1-git-send-email-tmgrennan@gmail.com> In-Reply-To: <1330566326-26075-1-git-send-email-tmgrennan@gmail.com> References: <1330566326-26075-1-git-send-email-tmgrennan@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: - Guard setup with test_expect_success - Unwound one loop to stay within the test_expect_success guard Signed-off-by: Tom Grennan --- t/t6300-for-each-ref.sh | 118 +++++++++++++++++++++++------------------------ 1 files changed, 58 insertions(+), 60 deletions(-) diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 1721784..ebba7d1 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -138,12 +138,13 @@ test_expect_success 'Check invalid format specifiers are errors' ' test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads ' -cat >expected <<\EOF +test_expect_success 'Check unformatted date fields output' ' + '" + cat >expected <<-EOF && 'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200' 'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200' EOF - -test_expect_success 'Check unformatted date fields output' ' + "' (git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads && git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual && test_cmp expected actual @@ -171,84 +172,85 @@ test_expect_success 'Check format "relative" date fields output' ' git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual ' -cat >expected <<\EOF +test_expect_success 'Check format "short" date fields output' ' + '" + cat >expected <<-EOF 'refs/heads/master' '2006-07-03' '2006-07-03' 'refs/tags/testtag' '2006-07-03' EOF - -test_expect_success 'Check format "short" date fields output' ' + "' f=short && (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Check format "local" date fields output' ' + '" + cat >expected <<-EOF 'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006' 'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006' EOF - -test_expect_success 'Check format "local" date fields output' ' - f=local && - (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && - git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && + "' + (git for-each-ref --shell --format="%(refname) %(committerdate:local) %(authordate:local)" refs/heads && + git for-each-ref --shell --format="%(refname) %(taggerdate:local)" refs/tags) >actual && test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Check format "iso8601" date fields output' ' + '" + cat >expected <<-EOF 'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200' 'refs/tags/testtag' '2006-07-03 17:18:45 +0200' EOF - -test_expect_success 'Check format "iso8601" date fields output' ' + "' f=iso8601 && (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Check format "rfc2822" date fields output' ' + '" + cat >expected <<-EOF 'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200' 'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200' EOF - -test_expect_success 'Check format "rfc2822" date fields output' ' + "' f=rfc2822 && (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads && git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual && test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Verify ascending sort' ' + cat >expected <<-EOF refs/heads/master refs/remotes/origin/master refs/tags/testtag EOF - -test_expect_success 'Verify ascending sort' ' git for-each-ref --format="%(refname)" --sort=refname >actual && test_cmp expected actual ' - -cat >expected <<\EOF +test_expect_success 'Verify descending sort' ' + cat >expected <<-EOF refs/tags/testtag refs/remotes/origin/master refs/heads/master EOF - -test_expect_success 'Verify descending sort' ' git for-each-ref --format="%(refname)" --sort=-refname >actual && test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Quoting style: shell' ' + '" + cat >expected <<-EOF 'refs/heads/master' 'refs/remotes/origin/master' 'refs/tags/testtag' EOF - -test_expect_success 'Quoting style: shell' ' + "' git for-each-ref --shell --format="%(refname)" >actual && test_cmp expected actual ' @@ -263,52 +265,51 @@ test_expect_success 'Quoting style: python' ' test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Quoting style: tcl' ' + cat >expected <<-EOF "refs/heads/master" "refs/remotes/origin/master" "refs/tags/testtag" EOF - -test_expect_success 'Quoting style: tcl' ' git for-each-ref --tcl --format="%(refname)" >actual && test_cmp expected actual ' -for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do - test_expect_success "more than one quoting style: $i" " - git for-each-ref $i 2>&1 | (read line && - case \$line in - \"error: more than one quoting style\"*) : happy;; - *) false - esac) - " -done - -cat >expected <<\EOF +test_expect_success 'more than one quoting styles' ' + cat >expected <<-EOF + error: more than one quoting style? + EOF + git for-each-ref --perl --shell 2>&1 | head -n 1 >actual && + test_cmp expected actual && + git for-each-ref -s --python 2>&1 | head -n 1 >actual && + test_cmp expected actual && + git for-each-ref --python --tcl 2>&1 | head -n 1 >actual && + test_cmp expected actual && + git for-each-ref --tcl --perl 2>&1 | head -n 1 >actual && + test_cmp expected actual +' +test_expect_success 'Check short refname format' ' + cat >expected <<-EOF master testtag EOF - -test_expect_success 'Check short refname format' ' (git for-each-ref --format="%(refname:short)" refs/heads && git for-each-ref --format="%(refname:short)" refs/tags) >actual && test_cmp expected actual ' -cat >expected <expected <<-EOF origin/master EOF - -test_expect_success 'Check short upstream format' ' git for-each-ref --format="%(upstream:short)" refs/heads >actual && test_cmp expected actual ' -cat >expected <expected <<-EOF 67a36f1 EOF - -test_expect_success 'Check short objectname format' ' git for-each-ref --format="%(objectname:short)" refs/heads >actual && test_cmp expected actual ' @@ -317,12 +318,11 @@ test_expect_success 'Check for invalid refname format' ' test_must_fail git for-each-ref --format="%(refname:INVALID)" ' -cat >expected <<\EOF +test_expect_success 'Check ambiguous head and tag refs (strict)' ' + cat >expected <<-EOF heads/master tags/master EOF - -test_expect_success 'Check ambiguous head and tag refs (strict)' ' git config --bool core.warnambiguousrefs true && git checkout -b newtag && echo "Using $datestamp" > one && @@ -334,23 +334,21 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' ' test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Check ambiguous head and tag refs (loose)' ' + cat >expected <<-EOF heads/master master EOF - -test_expect_success 'Check ambiguous head and tag refs (loose)' ' git config --bool core.warnambiguousrefs false && git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual && test_cmp expected actual ' -cat >expected <<\EOF +test_expect_success 'Check ambiguous head and tag refs II (loose)' ' + cat >expected <<-EOF heads/ambiguous ambiguous EOF - -test_expect_success 'Check ambiguous head and tag refs II (loose)' ' git checkout master && git tag ambiguous testtag^0 && git branch ambiguous testtag^0 && @@ -369,7 +367,7 @@ test_expect_success 'an unusual tag with an incomplete line' ' ' test_expect_success 'create tag with subject and body content' ' - cat >>msg <<-\EOF && + cat >msg <<-\EOF && the subject line first body line -- 1.7.8