Debian Codegraph @

tests/t420

raw
1 # t420 --- co -p -j
2 #
3 # Copyright (C) 2010-2022 Thien-Thi Nguyen
4 #
5 # This program is free software: you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation, either version 3 of
8 # the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty
12 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # See the GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 . $srcdir/common
19 split_std_out_err no
20 $hey echo ' -*- org -*-'
21 $hey type co
22
23 ##
24 # Check "co -p -jJOINLIST" for various values of JOINLIST,
25 # both valid and invalid. For valid values, also check output.
26 ##
27
28 actual=$wd/actual
29 normal=$actual.normal
30 expected=$wd/expected
31 doubt=$wd/diff.out
32
33 cp `bundled_commav two-with-branch` $v
34
35 ##
36 # * First, do invalid joinlist specs cause error?
37 # Here, invalid includes both "syntax invalid"
38 # as well as "syntax valid, semantics invalid".
39 ##
40
41 bad ()
42 {
43 # $1 -- title, in the form of ADJECTIVE-PHRASE
44 # $2 -- joinlist specification for "co -p -j"
45 $hey echo "* bad: $1 (-j$2)"
46
47 co -p -j"$2" $v > /dev/null &&
48 problem "co -p does not barf on invalid ($1) joinlist spec: $2"
49 ##
50 # TODO: Check error message
51 ##
52 }
53
54 bad 'empty' ','
55 bad 'unrecognized symbolic name 1' 'foo'
56 bad 'unrecognized symbolic name 2' 'foo:'
57 bad 'incomplete join-pair' '4.20:'
58 bad 'undefined common ancestor' '4.20'
59 bad 'incomplete join-pair, multiple' '4.20:4.21,4.20:'
60
61 ##
62 # * Now test with valid joinlist specs.
63 ##
64
65 try ()
66 {
67 # $1 -- title, in the form of ADJECTIVE-PHRASE
68 # $2 -- more options for "co -p"
69 # $3 -- expected output, with leading newline (discarded)
70 $hey echo "* try: $1 ($2)"
71 cmd="co -p $2"
72 title="($1) $cmd"
73
74 must '$cmd $v > $actual'
75 silence_means_death $actual "$title"
76
77 # Get rid of teporary filename conflict label.
78 sed '/^>/s/ .*//' $actual > $normal
79 echo "$3" | sed 1d > $expected
80
81 diff -u $expected $normal > $doubt
82 test -s $doubt && say_what $title
83 }
84
85 ##
86 # * The first handful of tests are "rational".
87 ##
88
89 try 'empty' \
90 -j '
91 nonempty
92 morejunk'
93
94 try 'simple' \
95 -j4.20:4.20.1.1 '
96 nonempty
97 <<<<<<< 4.21
98 morejunk
99 =======
100 evenmorejunk
101 >>>>>>>'
102
103 try 'simple, inverted' \
104 -j4.20.1.1:4.20 '
105 nonempty
106 <<<<<<< 4.21
107 morejunk
108 =======
109 >>>>>>>'
110
111 ##
112 # * The "two join specifications" tests are contrived
113 # primarily to ensure backward compatibility.
114 # The expected output is verbatim from RCS 5.7.
115 ##
116
117 try 'two join specifications' \
118 -j4.20:4.20.1.1,4.20:4.20.1.1 '
119 nonempty
120 <<<<<<< 4.21,4.20:4.20.1.1
121 <<<<<<< 4.21
122 morejunk
123 =======
124 evenmorejunk
125 >>>>>>>
126 =======
127 evenmorejunk
128 >>>>>>>'
129
130 try 'two join specifications, inverted' \
131 -j4.20.1.1:4.20,4.20.1.1:4.20 '
132 nonempty
133 <<<<<<< 4.21,4.20.1.1:4.20
134 <<<<<<< 4.21
135 morejunk
136 =======
137 >>>>>>>
138 =======
139 >>>>>>>'
140
141 exit 0
142
143 # t420 ends here