| 1 |
# t300 --- rlog on invalid RCS file |
| 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 |
## |
| 19 |
# We expect rlog to barf on an invalid RCS file. |
| 20 |
# |
| 21 |
# This test checks that rlog exits failurefully, but DOES NOT |
| 22 |
# check the error message. Invalid RCS files are formed first |
| 23 |
# by direct construction, then by introducing bad syntax into |
| 24 |
# otherwise well-formed RCS files, then by truncating otherwise |
| 25 |
# well-formed RCS files. |
| 26 |
# |
| 27 |
# TODO: Validate error message. |
| 28 |
## |
| 29 |
|
| 30 |
. $srcdir/common |
| 31 |
split_std_out_err no |
| 32 |
|
| 33 |
echo ' -*-org-*-' |
| 34 |
echo '* rlog:' `which rlog` |
| 35 |
|
| 36 |
# No file specified is a degenerate form of "invalid file". |
| 37 |
rlog && problem 'rlog with no args did not barf' |
| 38 |
|
| 39 |
barfstars='*' |
| 40 |
|
| 41 |
barf () |
| 42 |
{ |
| 43 |
# $1 -- title, in the form of ADJECTIVE-PHRASE |
| 44 |
# $2 -- shell command to create $v |
| 45 |
blurb="on invalid ($1) RCS file" |
| 46 |
echo "$barfstars (barf) $1" |
| 47 |
must "$2" |
| 48 |
$hey sed 's/^/|/' $v |
| 49 |
rlog $v |
| 50 |
res=$? |
| 51 |
test 0 = $res && problem "rlog did not barf $blurb" |
| 52 |
test 1 = $res || problem "bad rlog exit value ($res) $blurb" |
| 53 |
} |
| 54 |
|
| 55 |
barf 'zero size' \ |
| 56 |
'touch $v' |
| 57 |
|
| 58 |
barf 'blatant syntax error' \ |
| 59 |
'echo random junk > $v' |
| 60 |
|
| 61 |
barf 'bad keyword in header' \ |
| 62 |
'sed 10s/author/bother/ `bundled_commav zblob` > $v' |
| 63 |
|
| 64 |
barf 'missing author value in header' \ |
| 65 |
'sed 10s/.ttn// `bundled_commav zblob` > $v' |
| 66 |
|
| 67 |
barf 'invalid substitution mode' \ |
| 68 |
'sed 6s/b/BAD/ `bundled_commav zblob` > $v' |
| 69 |
|
| 70 |
barf 'head names a non-existent revision' \ |
| 71 |
'sed 1s/1/2/g `bundled_commav one` > $v' |
| 72 |
|
| 73 |
barf 'spurious edits w/o corresponding index' \ |
| 74 |
'sed "20s/1.7/1.6/;22,26d" `bundled_commav b.d/1612,v` > $v' |
| 75 |
|
| 76 |
zinvasion () |
| 77 |
{ |
| 78 |
# $1 -- RCS file |
| 79 |
# $2 -- (optional) list of line numbers |
| 80 |
# that are part of an @TEXT@ block |
| 81 |
echo "* (zinvasion) $1" |
| 82 |
commav=$1 |
| 83 |
atatlist="$2" |
| 84 |
lines=`wc -l "$commav" | sed 's/ .*//'` |
| 85 |
line=0 |
| 86 |
z=z |
| 87 |
|
| 88 |
test "$atatlist" && atatlist=" $atatlist " |
| 89 |
while test ! $line = $lines && line=`expr 1 + $line` ; do |
| 90 |
|
| 91 |
test "$atatlist" && |
| 92 |
case "$atatlist" in |
| 93 |
*" $line "*) z='z@z' ;; |
| 94 |
*) z=z ;; |
| 95 |
esac |
| 96 |
|
| 97 |
barf 'typo at beginning of line '$line \ |
| 98 |
'sed '$line's/^/'$z'/ '$commav' > $v' |
| 99 |
|
| 100 |
# Only do substutition (and testing) for non-empty lines. |
| 101 |
if [ "`sed -n ${line}p $commav`" ] ; then |
| 102 |
|
| 103 |
barf 'typo at first char of line '$line \ |
| 104 |
'sed '$line's/^./'$z'/ '$commav' > $v' |
| 105 |
|
| 106 |
barf 'typo at last char of line '$line \ |
| 107 |
'sed '$line's/.$/'$z'/ '$commav' > $v' |
| 108 |
fi |
| 109 |
|
| 110 |
barf 'typo at end of line '$line \ |
| 111 |
'sed '$line's/$/'$z'/ '$commav' > $v' |
| 112 |
done |
| 113 |
} |
| 114 |
|
| 115 |
barfstars='**' |
| 116 |
zinvasion `bundled_commav empty-minimal` |
| 117 |
zinvasion `bundled_commav empty` |
| 118 |
zinvasion `bundled_commav one` '19 20 22 23' |
| 119 |
|
| 120 |
jaws () |
| 121 |
{ |
| 122 |
# $1 -- RCS file |
| 123 |
eval `wc -l "$1" | sed 's/^/lines=/;s/ / commav=/'` |
| 124 |
line=1 |
| 125 |
|
| 126 |
echo "* (jaws) $commav" |
| 127 |
while test ! $line = $lines && line=`expr 1 + $line` ; do |
| 128 |
barf 'truncated at line '$line \ |
| 129 |
'sed '$line',\$d '$commav' > $v' |
| 130 |
done |
| 131 |
} |
| 132 |
|
| 133 |
jaws `bundled_commav empty-minimal` |
| 134 |
jaws `bundled_commav empty` |
| 135 |
jaws `bundled_commav one` |
| 136 |
|
| 137 |
zot () |
| 138 |
{ |
| 139 |
# $1 -- title |
| 140 |
# $2 -- sed script to munge two-with-branch |
| 141 |
barf "$1" 'sed -e "'"$2"'" `bundled_commav two-with-branch` > $v' |
| 142 |
} |
| 143 |
|
| 144 |
echo '* branch pointer weirdness' |
| 145 |
barfstars='**' |
| 146 |
|
| 147 |
zot 'is branch point itself' \ |
| 148 |
'/4.20.1.1;/s//4.20;/' |
| 149 |
|
| 150 |
zot 'not a revision' \ |
| 151 |
'/4.20.1.1;/s//4.20.1;/' |
| 152 |
|
| 153 |
zot 'not based on branch point' \ |
| 154 |
'/4.20.1.1;/s//1.1.1.1;/' |
| 155 |
|
| 156 |
zot 'missing' \ |
| 157 |
'/4.20.1.1;/s//;/' |
| 158 |
|
| 159 |
zot 'beyond branch point' \ |
| 160 |
'/^branches$/s/$/ 4.20.1.42/' |
| 161 |
|
| 162 |
echo '* log weirdness' |
| 163 |
|
| 164 |
zot 'repeated revno' \ |
| 165 |
'48s/.1.1$//' |
| 166 |
|
| 167 |
exit 0 |
| 168 |
|
| 169 |
# t300 ends here |