Debian Codegraph @

tests/t410

raw
1 # t410 --- co -p
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 . $srcdir/common-kn
20 split_std_out_err no
21 $hey echo ' -*- org -*-'
22 $hey type co
23
24 ##
25 # Check "co -p[REV]" works for various values of REV,
26 # both valid and invalid. For valid values, also check output.
27 ##
28
29 prep_b_comparison
30
31 ##
32 # * First, does invalid revision cause error?
33 ##
34
35 xfail ()
36 {
37 # $1 -- revision
38 rev=$1
39 $hey echo "* xfail: $subst"
40
41 co -p$rev $v > /dev/null &&
42 problem "co -p does not barf on invalid revision: $rev"
43 ##
44 # TODO: Check error message.
45 ##
46 }
47
48 xfail 0.0
49 xfail 1.0
50 xfail 11.11
51
52 ##
53 # * Now test with valid revisions, numeric and symbolic.
54 ##
55
56 ok ()
57 {
58 # $1 -- revision
59 # $2 -- (optional) normalized name
60 rev=$1
61 title="co -p$rev"
62 fn=`echo $rev | tr -d '.'`
63 expected="`bundled_commav b.d/${fn}.cou`"
64
65 $hey echo "* $rev"
66 must "co -p$rev $v > $actual"
67 normalize_b_and_diff "$title"
68 }
69
70 ok 1.1
71 ok 1.1.1.1
72 ok 1.1.1.2
73 ok 1.1.1.3
74 ok 1.1.1.4
75 ok 1.1.1.5
76 ok 1.1.1.6
77 ok 1.1.1.7
78 ok 1.2
79 ok 1.5
80 ok 1.6
81 ok 1.6.1.1
82 ok 1.6.1.2
83 ok 1.7
84 ok 1.8
85 ok 1.9
86
87 ok WOW
88 ok ZOW
89
90 ##
91 # * Now test special revision ‘$’.
92 ##
93
94 $hey echo '* special revision ‘$’'
95 must 'co -u $w'
96 must "co -p'$' $w > $actual"
97 diff -u $w $actual \
98 || problem "mismatch between ‘co -u’ and ‘co -p$’"
99
100 $hey echo '* likewise, w/ corrupt working file'
101 sed '1s/.YES.*//' $w > $w.corrupt
102 mv -f $w.corrupt $w
103 co -p'$' $w > $actual \
104 && problem '‘co -p$’ did not fail on corrupt working file'
105
106 $hey echo '* likewise, w/ "badly terminated keyword value" corruption'
107 sed '1s/.$//' $w > $w.corrupt
108 mv -f $w.corrupt $w
109 co -p'$' $w > $actual \
110 && problem '‘co -p$’ did not fail on corrupt working file'
111
112 ##
113 # * Also, check behavior for an unreadable comma-v.
114 ##
115
116 if chmod ugo-r $v && [ ! -r $v ] ; then
117 $hey echo '*' `ls -l $v` '(unreadable)'
118 co -p $v > /dev/null \
119 && problem 'co -p does not barf on unreadable comma-v'
120 fi
121 chmod ugo+r $v
122
123 exit 0
124
125 # t410 ends here