Skip to content

Commit 03e15fc

Browse files
sunshinecogitster
authored andcommitted
t8001/t8002 (blame): add blame -L tests
With the exception of a couple "corner case" checks in t8003 (and some indirect tests in t4211 of -L parsing code shared by log -L), there is no systematic checking of blame -L. Add tests to check blame -L directly. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e37f39c commit 03e15fc

File tree

1 file changed

+101
-3
lines changed

1 file changed

+101
-3
lines changed

t/annotate-tests.sh

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33

44
check_count () {
55
head= &&
6-
case "$1" in -h) head="$2"; shift; shift ;; esac &&
7-
echo "$PROG file $head" >&4 &&
8-
$PROG file $head >actual &&
6+
options= &&
7+
while :
8+
do
9+
case "$1" in
10+
-h) head="$2"; shift; shift ;;
11+
-*) options="$options $1"; shift ;;
12+
*) break ;;
13+
esac
14+
done &&
15+
echo "$PROG $options file $head" >&4 &&
16+
$PROG $options file $head >actual &&
917
perl -e '
1018
my %expect = (@ARGV);
1119
my %count = map { $_ => 0 } keys %expect;
@@ -142,3 +150,93 @@ test_expect_success 'setup obfuscated email' '
142150
test_expect_success 'blame obfuscated email' '
143151
check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
144152
'
153+
154+
test_expect_success 'blame -L 1 (all)' '
155+
check_count -L1 A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
156+
'
157+
158+
test_expect_success 'blame -L , (all)' '
159+
check_count -L, A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
160+
'
161+
162+
test_expect_success 'blame -L X (X to end)' '
163+
check_count -L5 B1 1 C 1 D 1 "A U Thor" 1
164+
'
165+
166+
test_expect_success 'blame -L X, (X to end)' '
167+
check_count -L5, B1 1 C 1 D 1 "A U Thor" 1
168+
'
169+
170+
test_expect_success 'blame -L ,Y (up to Y)' '
171+
check_count -L,3 A 1 B2 1 E 1
172+
'
173+
174+
test_expect_success 'blame -L X,X' '
175+
check_count -L3,3 B2 1
176+
'
177+
178+
test_expect_success 'blame -L X,Y' '
179+
check_count -L3,6 B 1 B1 1 B2 1 D 1
180+
'
181+
182+
test_expect_success 'blame -L Y,X (undocumented)' '
183+
check_count -L6,3 B 1 B1 1 B2 1 D 1
184+
'
185+
186+
test_expect_success 'blame -L X,+1' '
187+
check_count -L3,+1 B2 1
188+
'
189+
190+
test_expect_success 'blame -L X,+N' '
191+
check_count -L3,+4 B 1 B1 1 B2 1 D 1
192+
'
193+
194+
test_expect_success 'blame -L X,-1' '
195+
check_count -L3,-1 B2 1
196+
'
197+
198+
test_expect_success 'blame -L X,-N' '
199+
check_count -L6,-4 B 1 B1 1 B2 1 D 1
200+
'
201+
202+
test_expect_success 'blame -L /RE/ (RE to end)' '
203+
check_count -L/evil/ C 1 "A U Thor" 1
204+
'
205+
206+
test_expect_success 'blame -L /RE/,/RE2/' '
207+
check_count -L/robot/,/green/ A 1 B 1 B2 1 D 1 E 1
208+
'
209+
210+
test_expect_success 'blame -L X,/RE/' '
211+
check_count -L5,/evil/ B1 1 D 1 "A U Thor" 1
212+
'
213+
214+
test_expect_success 'blame -L /RE/,Y' '
215+
check_count -L/99/,7 B1 1 D 1 "A U Thor" 1
216+
'
217+
218+
test_expect_success 'blame -L /RE/,+N' '
219+
check_count -L/99/,+3 B1 1 D 1 "A U Thor" 1
220+
'
221+
222+
test_expect_success 'blame -L /RE/,-N' '
223+
check_count -L/99/,-3 B 1 B2 1 D 1
224+
'
225+
226+
test_expect_success 'blame -L X (X > nlines)' '
227+
test_must_fail $PROG -L12345 file
228+
'
229+
230+
test_expect_success 'blame -L ,Y (Y > nlines)' '
231+
test_must_fail $PROG -L,12345 file
232+
'
233+
234+
test_expect_success 'blame -L bogus' '
235+
test_must_fail $PROG -L file &&
236+
test_must_fail $PROG -L1,+ file &&
237+
test_must_fail $PROG -L1,- file &&
238+
test_must_fail $PROG -LX file &&
239+
test_must_fail $PROG -L1,X file &&
240+
test_must_fail $PROG -L1,+N file &&
241+
test_must_fail $PROG -L1,-N file
242+
'

0 commit comments

Comments
 (0)