git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH] blame: Add tests for -L/start/,/end/
Date: Fri, 16 Jul 2010 15:35:07 +0000	[thread overview]
Message-ID: <1279294507-9238-1-git-send-email-avarab@gmail.com> (raw)

git-pickaxe (later git-blame) gained support for the -L/start/,/end/
form in 2006 (931233bc66 by Junio C Hamano), but nothing was added to
test this functionality. Change that by adding more -L tests to
t8003-blame.sh.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t8003-blame.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh
index 230143c..2a3e169 100755
--- a/t/t8003-blame.sh
+++ b/t/t8003-blame.sh
@@ -175,6 +175,59 @@ test_expect_success 'blame -L with invalid end' '
 	grep "has only 2 lines" errors
 '
 
+for comma in '' ','
+do
+	# The comma in -L/regex/, is optional
+	test_expect_success "blame -L/start/$comma" "
+		git blame -L'/[E]F/$comma' cow >current 2>errors &&
+		! test -s errors &&
+		head -n 1 current | grep DEF &&
+		tail -n 1 current | grep GHIJK
+	"
+done
+
+test_expect_success 'blame -L/start/,/end/' '
+	git blame -L"/[E]F/,/^X/" cow >current 2>errors &&
+	! test -s errors &&
+	head -n 1 current | grep DEF &&
+	tail -n 1 current | grep XXXX
+'
+
+test_expect_success 'blame -L/start/,INT' '
+	git blame -L"/[C]/,2" cow >current 2>errors &&
+	! test -s errors &&
+	head -n 1 current | grep ABC &&
+	tail -n 1 current | grep DEF
+'
+
+test_expect_success 'blame -LINT,/end/' '
+	git blame -L3,/GH/ cow  >current 2>errors &&
+	! test -s errors &&
+	head -n 1 current | grep XXXX &&
+	tail -n 1 current | grep GHIJK
+'
+
+test_expect_success 'blame -L,/end/' '
+	git blame -L",/^X/" cow >current 2>errors &&
+	! test -s errors &&
+	head -n 1 current | grep ABC &&
+	tail -n 1 current | grep XXXX
+'
+
+test_expect_success 'blame -L/no match/' '
+	! git blame -L/hlagh/ cow >current 2>errors &&
+	grep hlagh errors &&
+	! test -s current
+'
+
+test_expect_success 'blame -L/invalid regex/' '
+	# At least GNU, Solaris and FreeBSD (and by extension, Mac OS X)
+	# complain about this
+	! git blame -L/[b-a]/ cow >current 2>errors &&
+	grep b-a errors &&
+	! test -s current
+'
+
 test_expect_success 'indent of line numbers, nine lines' '
 	git blame nine_lines >actual &&
 	test $(grep -c "  " actual) = 0
-- 
1.7.0.4

             reply	other threads:[~2010-07-16 15:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16 15:35 Ævar Arnfjörð Bjarmason [this message]
2010-07-19 21:09 ` [PATCH] blame: Add tests for -L/start/,/end/ Junio C Hamano
2010-07-19 21:21   ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1279294507-9238-1-git-send-email-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).