git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Henderson <henderson.bj@gmail.com>
To: git@vger.kernel.org
Cc: peff@peff.net, e@80x24.org, Brian Henderson <henderson.bj@gmail.com>
Subject: [PATCH v2 2/3] diff-highlight: add failing test for handling --graph output.
Date: Wed, 17 Aug 2016 08:31:23 -0700	[thread overview]
Message-ID: <20160817153124.7770-3-henderson.bj@gmail.com> (raw)
In-Reply-To: <20160817153124.7770-1-henderson.bj@gmail.com>
In-Reply-To: <20160810085635.GA1672@starla>

Signed-off-by: Brian Henderson <henderson.bj@gmail.com>
---
 contrib/diff-highlight/t/t9400-diff-highlight.sh | 13 +++++++
 contrib/diff-highlight/t/test-diff-highlight.sh  | 43 ++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/contrib/diff-highlight/t/t9400-diff-highlight.sh b/contrib/diff-highlight/t/t9400-diff-highlight.sh
index 8eff178..39707c6 100755
--- a/contrib/diff-highlight/t/t9400-diff-highlight.sh
+++ b/contrib/diff-highlight/t/t9400-diff-highlight.sh
@@ -59,4 +59,17 @@ test_expect_success 'diff-highlight does not highlight mismatched hunk size' '
 
 # TODO add multi-byte test
 
+test_expect_success 'diff-highlight highlights the beginning of a line' '
+	dh_graph_test \
+		"aaa\nbbb\nccc\n" \
+		"aaa\n0bb\nccc\n" \
+		"aaa\nb0b\nccc\n" \
+"
+ aaa
+-${CW}b${CR}bb
++${CW}0${CR}bb
+ ccc
+"
+'
+
 test_done
diff --git a/contrib/diff-highlight/t/test-diff-highlight.sh b/contrib/diff-highlight/t/test-diff-highlight.sh
index 38323e8..67f742c 100644
--- a/contrib/diff-highlight/t/test-diff-highlight.sh
+++ b/contrib/diff-highlight/t/test-diff-highlight.sh
@@ -64,6 +64,49 @@ dh_commit_test() {
 	test_cmp commit.exp commit.act
 }
 
+dh_graph_test() {
+	a="$1" b="$2" c="$3"
+
+	{
+		printf "$a" >file
+		git add file
+		git commit -m"Add a file"
+
+		printf "$b" >file
+		git commit -am"Update a file"
+
+		git checkout -b branch
+		printf "$c" >file
+		git commit -am"Update a file on branch"
+
+		git checkout master
+		printf "$a" >file
+		git commit -am"Update a file again"
+
+		git checkout branch
+		printf "$b" >file
+		git commit -am"Update a file similar to master"
+
+		git merge master
+		git checkout master
+		git merge branch --no-ff
+	} >/dev/null 2>&1
+
+	git log -p --graph --no-merges >graph.raw
+
+	# git log --graph orders the commits different than git log so we hack it by
+	# using sed to remove the graph part. We know from other tests, that DIFF_HIGHLIGHT
+	# works without the graph, so there should be no diff when running it with
+	# and without.
+	<graph.raw sed -e 's"^\(*\|| \||/\)\+""' -e 's"^  ""' | "$DIFF_HIGHLIGHT" >graph.exp
+	<graph.raw "$DIFF_HIGHLIGHT" | sed -e 's"^\(*\|| \||/\)\+""' -e 's"^  ""' >graph.act &&
+
+	test -s graph.act &&
+	# ignore whitespace since we're using a hacky sed command to remove the graph
+	# parts.
+	git diff -b --no-index graph.exp graph.act
+}
+
 test_chomp_eof() {
 	perl -pe 'chomp if eof'
 }
-- 
2.9.0


  parent reply	other threads:[~2016-08-17 15:32 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-30 15:11 [PATCH 0/3] diff-highlight: add support for git log --graph output Brian Henderson
2016-07-30 15:11 ` [PATCH 1/3] diff-highlight: add some tests Brian Henderson
2016-08-10  8:56   ` Eric Wong
2016-08-15 16:20     ` Brian Henderson
2016-08-15 16:25       ` Junio C Hamano
2016-08-17 15:31     ` [PATCH v2 0/3] diff-highlight: add support for git log --graph output Brian Henderson
2016-08-19 21:19       ` Eric Wong
2016-08-19 21:23         ` Jeff King
2016-08-17 15:31     ` [PATCH v2 1/3] diff-highlight: add some tests Brian Henderson
2016-08-17 19:09       ` Junio C Hamano
2016-08-19 14:42         ` Brian Henderson
2016-08-19 14:51           ` Jeff King
2016-08-19 15:13             ` Brian Henderson
2016-08-19 17:08             ` [PATCH v3 0/3] diff-highlight: add support for git log --graph output Brian Henderson
2016-08-19 17:08             ` [PATCH v3 1/3] diff-highlight: add some tests Brian Henderson
2016-08-19 18:10               ` Junio C Hamano
2016-08-19 19:30                 ` Brian Henderson
2016-08-19 20:56                   ` Eric Wong
2016-08-19 20:18                 ` [PATCH] " Brian Henderson
2016-08-19 20:44                   ` Junio C Hamano
2016-08-19 21:04                     ` Jeff King
2016-08-19 22:31                       ` Junio C Hamano
2016-08-22 15:55                         ` Brian Henderson
2016-08-23  4:12                           ` Jeff King
2016-08-29 17:33                             ` [PATCH v4 0/3] diff-highlight: add support for --graph option Brian Henderson
2016-08-29 17:33                               ` [PATCH v4 1/3] diff-highlight: add some tests Brian Henderson
2016-08-29 17:33                               ` [PATCH v4 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-08-29 17:33                               ` [PATCH v4 3/3] diff-highlight: add support for " Brian Henderson
2016-08-29 21:37                               ` [PATCH v4 0/3] diff-highlight: add support for --graph option Junio C Hamano
2016-08-30 14:07                                 ` Brian Henderson
2016-08-30 14:07                                   ` [PATCH v4 1/3] diff-highlight: add some tests Brian Henderson
2016-08-30 14:07                                   ` [PATCH v4 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-08-30 14:07                                   ` [PATCH v4 3/3] diff-highlight: add support for " Brian Henderson
2016-08-31  5:02                                   ` [PATCH v4 0/3] diff-highlight: add support for --graph option Jeff King
2016-08-31  5:02                                     ` [PATCH 1/3] diff-highlight: ignore test cruft Jeff King
2016-08-31  5:03                                     ` [PATCH 2/3] diff-highlight: add multi-byte tests Jeff King
2016-08-31  5:05                                     ` [PATCH 3/3] diff-highlight: avoid highlighting combined diffs Jeff King
2016-08-30  8:11                               ` [PATCH v4 0/3] diff-highlight: add support for --graph option Jeff King
2016-08-19 21:05                   ` [PATCH] diff-highlight: add some tests Junio C Hamano
2016-08-19 17:08             ` [PATCH v3 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-08-19 18:25               ` Junio C Hamano
2016-08-19 17:08             ` [PATCH v3 3/3] diff-highlight: add support for " Brian Henderson
2016-08-19 18:27               ` Junio C Hamano
2016-08-17 15:31     ` Brian Henderson [this message]
2016-08-17 19:18       ` [PATCH v2 2/3] diff-highlight: add failing test for handling " Junio C Hamano
2016-08-17 15:31     ` [PATCH v2 3/3] diff-highlight: add support for " Brian Henderson
2016-08-19 14:37       ` Jeff King
2016-08-15 16:40   ` [PATCH 1/3] diff-highlight: add some tests Lars Schneider
2016-08-16 20:48     ` Junio C Hamano
2016-08-24  9:38       ` Lars Schneider
2016-07-30 15:11 ` [PATCH 2/3] diff-highlight: add failing test for handling --graph output Brian Henderson
2016-07-30 15:11 ` [PATCH 3/3] diff-highlight: add support for " Brian Henderson
2016-08-01 17:16   ` Junio C Hamano
2016-08-04 15:02     ` [PATCH] diff-highlight: Add comment for our assumption about " Brian Henderson

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=20160817153124.7770-3-henderson.bj@gmail.com \
    --to=henderson.bj@gmail.com \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).