diff-highlight: add failing test for handling --graph output

Signed-off-by: Brian Henderson <henderson.bj@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Henderson committed Aug 29, 2016 at 10:33 UTC caf5ea707c2a412cdb61ef694678673b4cbec550
1 file changed +62
contrib/diff-highlight/t/t9400-diff-highlight.sh
+62
@@ -49,6 +49,55 @@ test_strip_patch_header () {
49 sed -n '/^@@/,$p' $*
50 }
51
52 +# dh_test_setup_history generates a contrived graph such that we have at least
53 +# 1 nesting (E) and 2 nestings (F).
54 +#
55 +# A branch
56 +# /
57 +# D---E---F master
58 +#
59 +# git log --all --graph
60 +# * commit
61 +# | A
62 +# | * commit
63 +# | | F
64 +# | * commit
65 +# |/
66 +# | E
67 +# * commit
68 +# D
69 +#
70 +dh_test_setup_history () {
71 + echo "file1" >file1 &&
72 + echo "file2" >file2 &&
73 + echo "file3" >file3 &&
74 +
75 + cat file1 >file &&
76 + git add file &&
77 + git commit -m "D" &&
78 +
79 + git checkout -b branch &&
80 + cat file2 >file &&
81 + git commit -a -m "A" &&
82 +
83 + git checkout master &&
84 + cat file2 >file &&
85 + git commit -a -m "E" &&
86 +
87 + cat file3 >file &&
88 + git commit -a -m "F"
89 +}
90 +
91 +left_trim () {
92 + "$PERL_PATH" -pe 's/^\s+//'
93 +}
94 +
95 +trim_graph () {
96 + # graphs start with * or |
97 + # followed by a space or / or \
98 + "$PERL_PATH" -pe 's@^((\*|\|)( |/|\\))+@@'
99 +}
100 +
101 test_expect_success 'diff-highlight highlights the beginning of a line' '
102 cat >a <<-\EOF &&
103 aaa
@@ -160,4 +209,17 @@ test_expect_failure 'diff-highlight highlights mismatched hunk size' '
209
210 # TODO add multi-byte test
211
212 +test_expect_failure 'diff-highlight works with the --graph option' '
213 + dh_test_setup_history &&
214 +
215 + # topo-order so that the order of the commits is the same as with --graph
216 + # trim graph elements so we can do a diff
217 + # trim leading space because our trim_graph is not perfect
218 + git log --branches -p --topo-order |
219 + "$DIFF_HIGHLIGHT" | left_trim >graph.exp &&
220 + git log --branches -p --graph |
221 + "$DIFF_HIGHLIGHT" | trim_graph | left_trim >graph.act &&
222 + test_cmp graph.exp graph.act
223 +'
224 +
225 test_done