|
1 #!/bin/sh |
|
2 |
|
3 # GNU diff is the reference for all of these results. |
|
4 |
|
5 hgdiff() { |
|
6 hg diff "$@" | sed "s/\(\(---\|+++\) [a-zA-Z0-9_/.-]*\).*/\1/" |
|
7 } |
|
8 |
|
9 test_added_blank_lines() { |
|
10 printf '\nhello world\n\ngoodbye world\n\n' >foo |
|
11 |
|
12 echo '>>> two diffs showing three added lines <<<' |
|
13 hgdiff |
|
14 hgdiff -b |
|
15 |
|
16 echo '>>> no diffs <<<' |
|
17 hgdiff -B |
|
18 hgdiff -Bb |
|
19 } |
|
20 |
|
21 test_added_horizontal_space_first_on_a_line() { |
|
22 printf '\t hello world\ngoodbye world\n' >foo |
|
23 |
|
24 echo '>>> four diffs showing added space first on the first line <<<' |
|
25 hgdiff |
|
26 hgdiff -b |
|
27 hgdiff -B |
|
28 hgdiff -Bb |
|
29 } |
|
30 |
|
31 test_added_horizontal_space_last_on_a_line() { |
|
32 printf 'hello world\t \ngoodbye world\n' >foo |
|
33 |
|
34 echo '>>> two diffs showing space appended to the first line <<<' |
|
35 hgdiff |
|
36 hgdiff -B |
|
37 |
|
38 echo '>>> no diffs <<<' |
|
39 hgdiff -b |
|
40 hgdiff -Bb |
|
41 } |
|
42 |
|
43 test_added_horizontal_space_in_the_middle_of_a_word() { |
|
44 printf 'hello world\ngood bye world\n' >foo |
|
45 |
|
46 echo '>>> four diffs showing space inserted into "goodbye" <<<' |
|
47 hgdiff |
|
48 hgdiff -B |
|
49 hgdiff -b |
|
50 hgdiff -Bb |
|
51 } |
|
52 |
|
53 test_increased_horizontal_whitespace_amount() { |
|
54 printf 'hello world\ngoodbye\t\t \tworld\n' >foo |
|
55 |
|
56 echo '>>> two diffs showing changed whitespace amount in the last line <<<' |
|
57 hgdiff |
|
58 hgdiff -B |
|
59 |
|
60 echo '>>> no diffs <<<' |
|
61 hgdiff -b |
|
62 hgdiff -Bb |
|
63 } |
|
64 |
|
65 test_added_blank_line_with_horizontal_whitespace() { |
|
66 printf 'hello world\n \t\ngoodbye world\n' >foo |
|
67 |
|
68 echo '>>> four diffs showing added blank line w/horizontal space <<<' |
|
69 hgdiff |
|
70 hgdiff -B |
|
71 hgdiff -b |
|
72 hgdiff -Bb |
|
73 } |
|
74 |
|
75 hg init |
|
76 printf 'hello world\ngoodbye world\n' >foo |
|
77 hg ci -Amfoo -ufoo -d '0 0' |
|
78 |
|
79 test_added_blank_lines |
|
80 test_added_horizontal_space_first_on_a_line |
|
81 test_added_horizontal_space_last_on_a_line |
|
82 test_added_horizontal_space_in_the_middle_of_a_word |
|
83 test_increased_horizontal_whitespace_amount |
|
84 test_added_blank_line_with_horizontal_whitespace |