Debian Codegraph @

tests/t999

raw
1 # t999 --- the original src/rcstest
2 #
3 # Copyright (C) 2010-2022 Thien-Thi Nguyen
4 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
5 #
6 # This program is free software: you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation, either version 3 of
9 # the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty
13 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 # See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 ##
20 # Test RCS by creating files RCS/a.* and RCS/a.c (in $wd).
21 # If all goes well, output nothing.
22 # Otherwise, send a message to standard output.
23 #
24 # Exit status is 0 if OK, 1 if an RCS bug is found, and 2
25 # if scaffolding fails (for problems in the test itself).
26 # When VERBOSE=1, output more debugging info.
27 #
28 # If diff outputs "No differences encountered" when comparing
29 # identical files, then this test may also output these noise
30 # lines; ignore them.
31 ##
32
33 . $srcdir/common
34
35 failed ()
36 {
37 problem "$@" failed
38 }
39
40 split_std_out_err
41 cd $wd
42 # Avoid tr(1) if possible; it's not portable, and it can't handle
43 # null bytes. Our substitute exclusive-ORs with '\n'; this ensures
44 # null bytes on output, which is even better than `tr', since some
45 # diffs think a file is binary only if it contains null bytes.
46 xorlf='../btdt xorlf'
47 TMPDIR=`pwd` ; export TMPDIR
48
49 : ${DIFF=diff}
50
51 RCSINIT=-x
52 export RCSINIT
53
54 SLASH=/
55 RCSfile=RCS${SLASH}a.c
56 RCS_alt=RCS${SLASH}a.d
57 lockfile=RCS${SLASH}a._
58
59 if test x"$VERBOSE" = x1
60 then q= ; set -x
61 else q=-q
62 fi
63
64 mkdir RCS
65
66 rm -f a.* $RCSfile $RCS_alt $lockfile &&
67 echo 1.1 >a.11 &&
68 echo 1.1.1.1 >a.3x1 &&
69 echo 1.2 >a.12 || { echo "#initialization failed"; exit 2; }
70
71 case "`$DIFF -c a.11 a.3x1`" in
72 *!\ 1.1.1.1)
73 diff="$DIFF -c";;
74 *)
75 echo "#warning: $DIFF -c does not work, so diagnostics may be cryptic"
76 diff=$DIFF
77 esac
78
79 rcs -i -L -ta.11 $q a.c &&
80 test -r $RCSfile || problem 'rcs -i -L failed; perhaps improper install'
81
82 rlog a.c >/dev/null || problem 'rlog failed on empty RCS file'
83 rm -f $RCSfile || exit 2
84
85 mm1='This is a log message that
86 spans multiple lines but does NOT
87 end in newline.'
88 mm2="
89
90 $mm1
91
92 Actually, for THIS log message, that is not entirely true;
93 we prefix and postfix several spurious newlines.
94
95
96 "
97
98 cp a.11 a.c &&
99 ci -ta.11 -m"$mm1" $q a.c &&
100 test -r $RCSfile &&
101 rcs -L $q a.c || failed 'ci+rcs -L'
102 test ! -f a.c || problem 'ci did not remove working file'
103 for l in '' '-l'
104 do
105 co $l $q a.c &&
106 test -f a.c || problem co $l did not create working file
107 $diff a.11 a.c || problem ci followed by co $l is not a no-op
108 done
109
110 cp a.12 a.c &&
111 ci -m"$mm2" $q a.c &&
112 co $q a.c &&
113 $diff a.12 a.c || failed 'ci+co'
114
115 rm -f a.c &&
116 co -r1.1 $q a.c &&
117 $diff a.11 a.c || problem 'cannot retrieve first revision'
118
119 rm -f a.c &&
120 cp a.3x1 a.c &&
121 ci -r1.1.1 -mm $q a.c &&
122 co -r1.1.1.1 $q a.c &&
123 $diff a.3x1 a.c || failed 'branches'
124
125 rm -f a.c &&
126 co -l $q a.c &&
127 ci -f -mm $q a.c &&
128 co -r1.3 $q a.c &&
129 $diff a.12 a.c || failed '(co -l; ci -f)'
130
131 rm -f a.c &&
132 co -l $q a.c &&
133 echo 1.4 >a.c &&
134 ci -l -mm $q a.c &&
135 echo error >a.c &&
136 ci -mm $q a.c || failed 'ci -l'
137
138 rm -f a.c &&
139 co -l $q a.c &&
140 echo 1.5 >a.c &&
141 ci -u -mm $q a.c &&
142 test -r a.c || problem 'ci -u did not create a working file'
143 rm -f a.c &&
144 echo error >a.c || exit 2
145 ci -mm $q a.c 2>/dev/null && problem 'ci -u did not unlock the file'
146
147 rm -f a.c &&
148 rcs -l $q a.c &&
149 co -u $q a.c || failed 'rcs -l + co -u'
150 rm -f a.c &&
151 echo error >a.c || exit 2
152 ci -mm $q a.c 2>/dev/null && problem 'co -u did not unlock the file'
153
154 rm -f a.c &&
155 cp a.11 a.c &&
156 co -f $q a.c || failed 'co -f'
157 $diff a.11 a.c >/dev/null && problem 'co -f had no effect'
158
159 co -p1.1 $q a.c >a.t &&
160 $diff a.11 a.t || failed 'co -p'
161
162 for n in n N
163 do
164 rm -f a.c &&
165 co -l $q a.c &&
166 echo $n >a.$n &&
167 cp a.$n a.c &&
168 ci -${n}n -mm $q a.c &&
169 co -rn $q a.c &&
170 $diff a.$n a.c || failed "ci -$n"
171 done
172
173 # Try POSIX, then BSD, then env vars.
174 me=`id -un 2>/dev/null`
175 if [ -z "$me" ] ; then
176 me=`whoami 2>/dev/null`
177 if [ -z "$me" ] ; then
178 me=$LOGNAME
179 if [ -z "$me" ] ; then
180 me=$USER
181 test "$me" || { echo >&2 "$0: cannot deduce user name" ; exit 2 ; }
182 fi
183 fi
184 fi
185
186 # Get the date of the previous revision in UTC.
187 date=`rlog -r a.c | sed -n '/^date: /{ s///; s/;.*//; p; q; }'` || exit
188 case $date in
189 [0-9][0-9][0-9]*[0-9]/[0-1][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-6][0-9]);;
190 *) problem "bad rlog date output: $date"
191 esac
192 PWD=`pwd` && export PWD &&
193 rm -f a.c &&
194 co -l $q a.c &&
195 sed 's/@/$/g' >a.kv <<EOF
196 @Author: w @
197 @Date: $date @
198 @Header: $PWD$SLASH$RCSfile 2.1 $date w seriously-spurious @
199 @Id: a.c 2.1 $date w seriously-spurious @
200 @Locker: @
201 * @Log: a.c @
202 * Revision 2.1 $date w
203 * m
204 *
205 @Name: Oz @
206 @RCSfile: a.c @
207 @Revision: 2.1 @
208 @Source: $PWD$SLASH$RCSfile @
209 @State: seriously-spurious @
210 EOF
211 test $? = 0 &&
212 sed 's/:.*\$/$/' a.kv >a.k &&
213 sed -e 's/w seriously-spurious [$]/w seriously-spurious '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl &&
214 sed s/Oz//g a.kv >a.e &&
215 sed s/Oz/N/g a.kv >a.N &&
216 sed -e '/\$/!d' -e 's/\$$/: old $/' a.k >a.o &&
217 sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v &&
218 cp a.o a.c &&
219 ci -d"$date" -nOz -sseriously-spurious -ww -u2.1 -mm $q a.c &&
220 $diff a.kv a.c || failed 'keyword expansion'
221 co -pOz -ko $q a.c >a.oo &&
222 $diff a.o a.oo || failed 'co -p -ko'
223 cp a.kv a.o && cp a.o a.b || exit 2
224 rcs -oOz $q a.c &&
225 rcs -l $q a.c &&
226 ci -k -u $q a.c &&
227 $diff a.kv a.c || failed 'ci -k'
228 sed -n 's/^[^$]*\$/$/p' a.kv >a.i &&
229 ident a.c >a.i1 &&
230 sed -e 1d -e 's/^[ ]*//' a.i1 >a.i2 &&
231 $diff a.i a.i2 || failed 'ident'
232
233 rcs -i $q a.c 2>/dev/null && problem 'rcs -i permitted existing file'
234
235 rm -f a.c &&
236 co -l $q a.c &&
237 echo 2.2 >a.c &&
238 ci -mm $q a.c &&
239 echo 1.1.1.2 >a.c &&
240 rcs -l1.1.1 $q a.c &&
241 ci -r1.1.1.2 -mm $q a.c &&
242 rcs -b1.1.1 $q a.c &&
243 test " `co -p $q a.c`" = ' 1.1.1.2' || failed 'rcs -b1.1.1'
244 rcs -b $q a.c &&
245 test " `co -p $q a.c`" = ' 2.2' || failed 'rcs -b'
246
247 echo 2.3 >a.c || exit 2
248 rcs -U $q a.c || failed 'rcs -U'
249 ci -mm $q a.c || problem 'rcs -U did not unset strict locking'
250 rcs -L $q a.c || failed 'rcs -L'
251 echo error >a.c || exit 2
252 ci -mm $q a.c 2>/dev/null && failed 'ci retest'
253
254 rm -f a.c &&
255 log0=`rlog -h a.c` &&
256 co -l $q a.c &&
257 ci -mm $q a.c &&
258 log1=`rlog -h a.c` &&
259 test " $log0" = " $log1" || problem 'unchanged ci did not revert'
260
261 rm -f a.c &&
262 rcs -nN:1.1 $q a.c &&
263 co -rN $q a.c &&
264 $diff a.11 a.c || failed 'rcs -n'
265
266 rm -f a.c &&
267 rcs -NN:2.1 $q a.c &&
268 co -rN $q a.c &&
269 $diff a.N a.c || failed 'rcs -N'
270
271 rm -f a.c &&
272 co -l $q a.c &&
273 echo ':::$''Log$' >a.c &&
274 ci -u -mm $q a.c &&
275 test " `sed '$!d' a.c`" = ' :::' || failed 'comment leader'
276
277 rm -f a.c &&
278 rcs -o2.2: $q a.c &&
279 co $q a.c &&
280 $diff a.e a.c || failed 'rcs -o'
281
282 rcsdiff -r1.1 -rOz $q a.c >a.0
283 case $? in
284 1) ;;
285 *) problem 'rcsdiff bad status'
286 esac
287 $DIFF a.11 a.kv >a.1
288 $diff a.0 a.1 || failed 'rcsdiff'
289
290 rcs -l2.1 $q a.c || failed 'rcs -l2.1'
291 for i in b k kv kvl o v
292 do
293 rm -f a.c &&
294 cp a.$i a.c &&
295 rcsdiff -k$i -rOz $q a.c || failed "rcsdiff -k$i"
296 done
297 co -p1.1 -ko $q a.c >a.t &&
298 $diff a.11 a.t || failed 'co -p1.1 -ko'
299 rcs -u2.1 $q a.c || failed 'rcs -u2.1'
300
301 rm -f a.c &&
302 rcsclean $q a.c &&
303 rcsclean -u $q a.c || problem 'rcsclean botched a nonexistent file'
304
305 rm -f a.c &&
306 co $q a.c &&
307 rcsclean -n $q a.c &&
308 rcsclean -n -u $q a.c &&
309 test -f a.c || problem 'rcsclean -n removed a file'
310
311 rm -f a.c &&
312 co $q a.c &&
313 rcsclean $q a.c &&
314 test ! -f a.c || problem 'rcsclean missed an unlocked file'
315
316 rm -f a.c &&
317 co -l $q a.c &&
318 rcsclean $q a.c &&
319 test -f a.c || problem 'rcsclean removed a locked file'
320 rcsclean -u $q a.c &&
321 test ! -f a.c || problem 'rcsclean -u missed an unchanged locked file'
322
323 rm -f a.c &&
324 co -l $q a.c &&
325 echo change >>a.c &&
326 rcsclean $q a.c &&
327 rcsclean $q -u a.c &&
328 test -f a.c || problem 'rcsclean removed a changed file'
329
330 rm -f a.c &&
331 co -l $q a.c &&
332 cat >a.c <<'EOF'
333 2.2
334 a
335 b
336 c
337 d
338 EOF
339 test $? = 0 &&
340 ci -l -mm $q a.c &&
341 co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c &&
342 ci -l -mm $q a.c &&
343 co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2
344 cat >a.0 <<'EOF'
345 2.3
346 a
347 b1
348 c
349 d1
350 EOF
351 cat >a.1 <<'EOF'
352 <<<<<<< a.c
353 new
354 =======
355 2.3
356 >>>>>>> 2.3
357 a
358 b1
359 c
360 d1
361 EOF
362 rcsmerge -E -r2.2 -r2.3 $q a.c
363 case $? in
364 0)
365 if $diff a.0 a.c >/dev/null
366 then echo "#warning: diff3 -E does not work, " \
367 "so merge and rcsmerge ignore overlaps and suppress overlap lines."
368 else
369 $diff a.1 a.c || problem 'rcsmerge failed (status 0)'
370 echo "#warning: The diff3 lib program exit status ignores overlaps," \
371 "so rcsmerge does not warn about overlap lines that it generates."
372 fi
373 ;;
374 1)
375 $diff a.1 a.c || problem 'rcsmerge failed (status 1)'
376 ;;
377 *)
378 problem 'rcsmerge bad status'
379 esac
380
381 cat >a.c <<'EOF'
382 #include <stdio.h>
383 int main() {
384 int c;
385 while ((c=getchar()) != EOF)
386 putchar(c ^ '\n');
387 return 0;
388 }
389 EOF
390 {
391 co -p $q a.c | $xorlf >a.24 &&
392 cp a.24 a.c &&
393 ciOut=`(ci -l -mm $q a.c 2>&1)` &&
394 case $ciOut in
395 ?*) echo >&2 "$ciOut"
396 esac &&
397 co -p $q a.c | $xorlf >a.c &&
398 rcsdiff -r2.3 $q a.c >/dev/null &&
399
400 echo 2.5 >a.c &&
401 ci -l -mm $q a.c &&
402 cp a.24 a.c &&
403 rcsdiff -r2.4 $q a.c >/dev/null
404 } || echo "#warning: Traditional diff is used, so RCS is limited to text files."
405
406 rcs -u -o2.4: $q a.c || failed 'rcs -u -o'
407
408 rcs -i -Aa.c -t- $q a.d || failed 'rcs -i -A'
409
410 # The ordering of symbolic names is inverted between RCS 5.7 and 5.8.
411 # That's why we sort. Ugly but true. Probably it would be best to
412 # remove this gratuitous reordering, but that would need to be done
413 # before 5.8. Hmmm...
414 rlog -r2.1 a.c >a.t &&
415 grep '^checked in with -k' a.t >/dev/null &&
416 sed '/^checked in with -k/d' a.t >a.u &&
417 $diff - a.u <<EOF
418
419 RCS file: RCS/a.c
420 Working file: a.c
421 head: 2.3
422 branch:
423 locks: strict
424 access list:
425 symbolic names:
426 N: 2.1
427 Oz: 2.1
428 n: 1.8
429 keyword substitution: kv
430 total revisions: 13; selected revisions: 1
431 description:
432 1.1
433 ----------------------------
434 revision 2.1
435 date: $date; author: w; state: seriously-spurious; lines: +14 -1
436 =============================================================================
437 EOF
438 test $? = 0 || failed 'rlog'
439
440 # Exercise RCSINIT processing.
441 RCSINIT="-wnobody $RCSINIT"
442
443 rlog a.c a.c >/dev/null
444 test $? = 0 || failed 'rlog with working file repeated'
445
446 test ! -f $lockfile || problem 'lock file not removed'
447
448 cd ..
449
450 exit 0
451
452 # t999 ends here