File: t430

package info (click to toggle)
rcs 5.10.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,348 kB
  • sloc: ansic: 47,019; sh: 4,939; makefile: 169
file content (176 lines) | stat: -rw-r--r-- 3,860 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# t430 --- co -p -k
#
# Copyright (C) 2010-2022 Thien-Thi Nguyen
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

. $srcdir/common
. $srcdir/common-kn
split_std_out_err no
$hey echo '                                    -*- org -*-'
$hey type co

##
# Check "co -p -kSUBST" works for various values of SUBST,
# both valid and invalid.  For valid values, also check output.
##

prep_b_comparison

doubt=$wd/diff.out
co='co -p1.2'

##
# * First, does invalid substitution mode cause error?
##

xfail ()
{
    # $1 -- substitution mode
    subst=$1
    $hey echo "* xfail: $subst"

    $co -k$subst $v > /dev/null &&
    problem "co -p -k does not barf on invalid substition mode: $subst"
##
#   TODO: Check error message.
##
}

xfail LOSE
xfail xfail
xfail kk
xfail oo
xfail bb

##
# * Now test with valid substitution mode, one of:
#   kv, kvl, k, o, b, v
##

ok ()
{
    # $1 -- substitution mode
    # $2 -- expected output, with leading newline (discarded)
    subst=$1
    title="$co -k$subst"
    # We normally zonk eol whitespace via ~/.emacs fragment:
    #  (add-to-list 'before-save-hook 'delete-trailing-whitespace)
    # So, to preserve "meaningful" (expected) eol whitespace, the
    # expected strings have lines ending in '|'; ignore those.
    # IWBN to use ^Z or somesuch, but not all seds can handle that.
    echo "$2" | sed '1d;s/|$//' > $expected
    $hey echo "* ok: $subst"

    must "$co -k$subst $v > $actual"
    normalize_b_and_diff "$title"
}

ok kv '
;; $Author: ttn $|
;; $Date: 2010/03/30 09:45:02 $|
;; $Header: /home/ttn/build/GNU/rcs/tests/fake/b,v 1.2 2010/03/30 09:45:02 ttn Exp $|
;; $Id: b,v 1.2 2010/03/30 09:45:02 ttn Exp $|
;; $Locker:  $|
;; $Name:  $|
;; $RCSfile: b,v $|
;; $Revision: 1.2 $|
;; $Source: /home/ttn/build/GNU/rcs/tests/fake/b,v $|
;; $State: Exp $|
;; $Log: b,v $|
;; Revision 1.2  2010/03/30 09:45:02  ttn|
;; Add empty headers.|
;;|'

##
#   The ‘kvl’ and ‘kv’ output are identical because there is no locker.
#   TODO: Add a case with locker.
##
ok kvl '
;; $Author: ttn $|
;; $Date: 2010/03/30 09:45:02 $|
;; $Header: /home/ttn/build/GNU/rcs/tests/fake/b,v 1.2 2010/03/30 09:45:02 ttn Exp $|
;; $Id: b,v 1.2 2010/03/30 09:45:02 ttn Exp $|
;; $Locker:  $|
;; $Name:  $|
;; $RCSfile: b,v $|
;; $Revision: 1.2 $|
;; $Source: /home/ttn/build/GNU/rcs/tests/fake/b,v $|
;; $State: Exp $|
;; $Log: b,v $|
;; Revision 1.2  2010/03/30 09:45:02  ttn|
;; Add empty headers.|
;;|'

ok k '
;; $Author$|
;; $Date$|
;; $Header$|
;; $Id$|
;; $Locker$|
;; $Name$|
;; $RCSfile$|
;; $Revision$|
;; $Source$|
;; $State$|
;; $Log$|
;; Revision 1.2  2010/03/30 09:45:02  ttn|
;; Add empty headers.|
;;|'

ok o '
;; $Author$|
;; $Date$|
;; $Header$|
;; $Id$|
;; $Locker$|
;; $Name$|
;; $RCSfile$|
;; $Revision$|
;; $Source$|
;; $State$|
;; $Log$|'

ok b '
;; $Author$|
;; $Date$|
;; $Header$|
;; $Id$|
;; $Locker$|
;; $Name$|
;; $RCSfile$|
;; $Revision$|
;; $Source$|
;; $State$|
;; $Log$|'

ok v '
;; ttn|
;; 2010/03/30 09:45:02|
;; /home/ttn/build/GNU/rcs/tests/fake/b,v 1.2 2010/03/30 09:45:02 ttn Exp|
;; b,v 1.2 2010/03/30 09:45:02 ttn Exp|
;; |
;; |
;; b,v|
;; 1.2|
;; /home/ttn/build/GNU/rcs/tests/fake/b,v|
;; Exp|
;; b,v|
;; Revision 1.2  2010/03/30 09:45:02  ttn|
;; Add empty headers.|
;;|'

exit 0

# t430 ends here