2 # Test suite for update-copyright.
3 # Copyright (C) 2009 Free Software Foundation, Inc.
4 # This file is part of the GNUlib Library.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
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/>.
19 diffout=`diff -u /dev/null /dev/null 2>&1`
20 if test x"$diffout" = x"" && test $? -eq 0; then
21 compare() { diff -u "$@"; }
23 compare() { cmp "$@"; }
26 TMP_BASE=update-copyright.test
28 ## ----------------------------- ##
29 ## Examples from documentation. ##
30 ## ----------------------------- ##
34 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
38 # Copyright (C) 1990-2005, 2007-2009 Free Software
43 * Copyright © 90,2005,2007-2009
44 * Free Software Foundation, Inc.
48 /* Copyright (C) 1990-2005, 2007-2009 Free Software
52 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
55 /* Copyright (C) 1990-2005, 2007-2009 Free Software
58 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
62 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
64 # Copyright (C) 1990-2005, 2007-2009 Free Software
68 UPDATE_COPYRIGHT_YEAR=2009 \
69 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
70 compare /dev/null $TMP-stdout || exit 1
71 compare - $TMP-stderr <<EOF || exit 1
72 $TMP.4: warning: FSF copyright statement not found
73 $TMP.5: warning: FSF copyright statement not found
75 compare - $TMP.1 <<EOF || exit 1
76 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
79 compare - $TMP.2 <<EOF || exit 1
80 # Copyright (C) 1990-2005, 2007-2009 Free Software
83 compare - $TMP.3 <<EOF || exit 1
85 * Copyright © 90,2005,2007-2009
86 * Free Software Foundation, Inc.
89 compare - $TMP.4 <<EOF || exit 1
90 /* Copyright (C) 1990-2005, 2007-2009 Free Software
93 compare - $TMP.5 <<EOF || exit 1
94 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
96 compare - $TMP.6 <<EOF || exit 1
97 /* Copyright (C) 1990-2005, 2007-2009 Free Software
100 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
103 compare - $TMP.7 <<EOF || exit 1
104 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
106 # Copyright (C) 1990-2005, 2007-2009 Free Software
110 UPDATE_COPYRIGHT_YEAR=2010 \
111 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
112 compare /dev/null $TMP-stdout || exit 1
113 compare - $TMP-stderr <<EOF || exit 1
114 $TMP.4: warning: FSF copyright statement not found
115 $TMP.5: warning: FSF copyright statement not found
117 compare - $TMP.1 <<EOF || exit 1
118 Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation,
121 compare - $TMP.2 <<EOF || exit 1
122 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
124 compare - $TMP.3 <<EOF || exit 1
126 * Copyright © 90, 2005, 2007-2010 Free Software Foundation, Inc.
129 compare - $TMP.4 <<EOF || exit 1
130 /* Copyright (C) 1990-2005, 2007-2009 Free Software
131 * Foundation, Inc. */
133 compare - $TMP.5 <<EOF || exit 1
134 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
136 compare - $TMP.6 <<EOF || exit 1
137 /* Copyright (C) 1990-2005, 2007-2009 Free Software
138 * Foundation, Inc. */
140 Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
142 compare - $TMP.7 <<EOF || exit 1
143 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
145 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
154 TMP=$TMP_BASE-current-year
155 YEAR=`/usr/bin/perl -e 'print [localtime]->[5] + 1900'`;
157 '\" Copyright (C) 2006
158 '\" Free Software Foundation,
161 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
162 compare /dev/null $TMP-stdout || exit 1
163 compare /dev/null $TMP-stderr || exit 1
164 compare - $TMP <<EOF || exit 1
165 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
169 ## ------------------ ##
170 ## Surrounding text. ##
171 ## ------------------ ##
173 TMP=$TMP_BASE-surrounding-text
176 dnl Undisturbed text.
178 dnl Free Software Foundation, Inc.
179 dnl Undisturbed text.
181 UPDATE_COPYRIGHT_YEAR=2010 \
182 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
183 compare /dev/null $TMP-stdout || exit 1
184 compare /dev/null $TMP-stderr || exit 1
185 compare - $TMP <<EOF || exit 1
187 dnl Undisturbed text.
188 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
189 dnl Undisturbed text.
193 ## --------------- ##
195 ## --------------- ##
197 TMP=$TMP_BASE-widest-prefix
199 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
200 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
201 #### 2008 Free Software Foundation, Inc.
203 UPDATE_COPYRIGHT_YEAR=2010 \
204 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
205 compare /dev/null $TMP-stdout || exit 1
206 compare /dev/null $TMP-stderr || exit 1
207 compare - $TMP <<EOF || exit 1
208 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
209 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
210 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
214 ## ------------------- ##
215 ## Prefix too large. ##
216 ## ------------------- ##
218 TMP=$TMP_BASE-prefix-too-large
220 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
221 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
222 #### 2008 Free Software Foundation, Inc.
224 UPDATE_COPYRIGHT_YEAR=2010 \
225 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
226 compare /dev/null $TMP-stdout || exit 1
227 compare - $TMP-stderr <<EOF || exit 1
228 $TMP: warning: FSF copyright statement not found
230 compare - $TMP <<EOF || exit 1
231 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
232 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
233 #### 2008 Free Software Foundation, Inc.
241 TMP=$TMP_BASE-blank-lines
243 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
245 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
246 #2008 Free Software Foundation, Inc.
248 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
250 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
251 2008 Free Software Foundation, Inc.
253 UPDATE_COPYRIGHT_YEAR=2010 \
254 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
255 compare /dev/null $TMP-stdout || exit 1
256 compare - $TMP-stderr <<EOF || exit 1
257 $TMP: warning: FSF copyright statement not found
259 compare - $TMP <<EOF || exit 1
260 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
262 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
263 #2008 Free Software Foundation, Inc.
265 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
267 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
268 2008 Free Software Foundation, Inc.
276 TMP=$TMP_BASE-leading-tabs
278 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
279 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
280 Software Foundation, Inc.
282 UPDATE_COPYRIGHT_YEAR=2010 \
283 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
284 compare /dev/null $TMP-stdout || exit 1
285 compare /dev/null $TMP-stderr || exit 1
286 compare - $TMP <<EOF || exit 1
287 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
288 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
289 2009-2010 Free Software Foundation, Inc.
293 ## -------------------- ##
294 ## Unusual whitespace. ##
295 ## -------------------- ##
297 TMP=$TMP_BASE-unusual-ws
299 # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
300 # 98, 1999, 2000, 2001, 2002, 2003,
\f 2004, 2005, 2006, 2007, 2008,
301 # 2009 Free Software Foundation, Inc.
303 UPDATE_COPYRIGHT_YEAR=2010 \
304 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
305 compare /dev/null $TMP-stdout || exit 1
306 compare /dev/null $TMP-stderr || exit 1
307 compare - $TMP <<EOF || exit 1
308 # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995,
309 # 1996, 1997, 98, 1999, 2000, 2001, 2002, 2003, 2004,
310 # 2005, 2006, 2007, 2008, 2009-2010 Free Software
319 TMP=$TMP_BASE-dos-eol
320 tr @ '\015' > $TMP <<\EOF
321 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
322 Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
323 Rem 2009 Free Software Foundation, Inc.@
325 UPDATE_COPYRIGHT_YEAR=2010 \
326 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
327 compare /dev/null $TMP-stdout || exit 1
328 compare /dev/null $TMP-stderr || exit 1
329 tr @ '\015' > $TMP-exp <<\EOF
330 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,@
331 Rem 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
332 Rem 2009-2010 Free Software Foundation, Inc.@
334 compare $TMP-exp $TMP || exit 1