Debian Codegraph @

tests/diff3

raw
1 #!/bin/sh
2 # This would malfunction in diff-3.4
3
4 . "${srcdir=.}/init.sh"; path_prepend_ ../src
5
6 echo a > a || framework_failure_
7 echo b > b || framework_failure_
8 echo c > c || framework_failure_
9 cat <<'EOF' > exp || framework_failure_
10 ====
11 1:1c
12 a
13 2:1c
14 b
15 3:1c
16 c
17 EOF
18
19 fail=0
20
21 # Use --diff-program=diff since --program-transform-name and similar are
22 # applied after 'make install'.
23 diff3 --diff-program=diff a b c > out 2> err || fail=1
24 compare exp out || fail=1
25 compare /dev/null err || fail=1
26
27 # Repeat, but with all three files the same:
28 diff3 --diff-program=diff a a a > out 2> err || fail=1
29 compare /dev/null out || fail=1
30 compare /dev/null err || fail=1
31
32 # This would have provoked a nontrivial leak prior to diffutils-3.5,
33 # due to the nontrivial list of diff_block structs.
34 seq 10 40|sed 's/1$/x/' > d || framework_failure_
35 seq 10 40|sed 's/5$/y/' > e || framework_failure_
36 seq 10 40|sed 's/8$/z/' > f || framework_failure_
37 cat <<'EOF' > exp40 || framework_failure_
38 ====1
39 1:2c
40 1x
41 2:2c
42 3:2c
43 11
44 ====2
45 1:6c
46 3:6c
47 15
48 2:6c
49 1y
50 ====3
51 1:9c
52 2:9c
53 18
54 3:9c
55 1z
56 ====1
57 1:12c
58 2x
59 2:12c
60 3:12c
61 21
62 ====2
63 1:16c
64 3:16c
65 25
66 2:16c
67 2y
68 ====3
69 1:19c
70 2:19c
71 28
72 3:19c
73 2z
74 ====1
75 1:22c
76 3x
77 2:22c
78 3:22c
79 31
80 ====2
81 1:26c
82 3:26c
83 35
84 2:26c
85 3y
86 ====3
87 1:29c
88 2:29c
89 38
90 3:29c
91 3z
92 EOF
93
94 diff3 --diff-program=diff d e f > out 2> err
95 compare exp40 out || fail=1
96 compare /dev/null err || fail=1
97
98 Exit $fail