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 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
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 © 1990, 2005, 2007-2010 Free Software Foundation, Inc.
129 compare - $TMP.4 <<EOF || exit 1
130 ## Copyright (C) 1990-2005, 2007-2009 Free Software
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
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.
148 UPDATE_COPYRIGHT_YEAR=2011 \
149 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
150 compare /dev/null $TMP-stdout || exit 1
151 compare - $TMP-stderr <<EOF || exit 1
152 $TMP.4: warning: FSF copyright statement not found
153 $TMP.5: warning: FSF copyright statement not found
155 compare - $TMP.1 <<EOF || exit 1
156 Copyright @copyright{} 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
157 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
158 2011 Free Software Foundation, Inc.
160 compare - $TMP.2 <<EOF || exit 1
161 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
162 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
163 # Free Software Foundation, Inc.
165 compare - $TMP.3 <<EOF || exit 1
167 * Copyright © 1990, 2005, 2007, 2008, 2009, 2010, 2011 Free
168 * Software Foundation, Inc.
171 compare - $TMP.4 <<EOF || exit 1
172 ## Copyright (C) 1990-2005, 2007-2009 Free Software
175 compare - $TMP.5 <<EOF || exit 1
176 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
178 compare - $TMP.6 <<EOF || exit 1
179 ## Copyright (C) 1990-2005, 2007-2009 Free Software
182 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
183 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
184 Free Software Foundation, Inc.
186 compare - $TMP.7 <<EOF || exit 1
187 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
189 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
190 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
191 # Free Software Foundation, Inc.
200 TMP=$TMP_BASE-current-year
201 YEAR=`/usr/bin/perl -e 'print [localtime]->[5] + 1900'`;
203 '\" Copyright (C) 2006
204 '\" Free Software Foundation,
207 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
208 compare /dev/null $TMP-stdout || exit 1
209 compare /dev/null $TMP-stderr || exit 1
210 compare - $TMP <<EOF || exit 1
211 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
213 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
214 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
215 compare /dev/null $TMP-stdout || exit 1
216 compare /dev/null $TMP-stderr || exit 1
217 compare - $TMP <<EOF || exit 1
218 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
222 ## ------------------ ##
223 ## Surrounding text. ##
224 ## ------------------ ##
226 TMP=$TMP_BASE-surrounding-text
229 dnl Undisturbed text.
231 dnl Free Software Foundation, Inc.
232 dnl Undisturbed text.
234 UPDATE_COPYRIGHT_YEAR=2010 \
235 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
236 compare /dev/null $TMP-stdout || exit 1
237 compare /dev/null $TMP-stderr || exit 1
238 compare - $TMP <<EOF || exit 1
240 dnl Undisturbed text.
241 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
242 dnl Undisturbed text.
246 ## --------------- ##
248 ## --------------- ##
250 TMP=$TMP_BASE-widest-prefix
252 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
253 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
254 #### 2008 Free Software Foundation, Inc.
256 UPDATE_COPYRIGHT_YEAR=2010 \
257 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
258 compare /dev/null $TMP-stdout || exit 1
259 compare /dev/null $TMP-stderr || exit 1
260 compare - $TMP <<EOF || exit 1
261 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
262 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
263 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
265 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
266 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
267 compare /dev/null $TMP-stdout || exit 1
268 compare /dev/null $TMP-stderr || exit 1
269 compare - $TMP <<EOF || exit 1
270 #### Copyright (C) 1976-1988, 1999-2008, 2010-2011 Free Software
271 #### Foundation, Inc.
275 ## ------------------- ##
276 ## Prefix too large. ##
277 ## ------------------- ##
279 TMP=$TMP_BASE-prefix-too-large
281 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
282 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
283 #### 2008 Free Software Foundation, Inc.
285 UPDATE_COPYRIGHT_YEAR=2010 \
286 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
287 compare /dev/null $TMP-stdout || exit 1
288 compare - $TMP-stderr <<EOF || exit 1
289 $TMP: warning: FSF copyright statement not found
291 compare - $TMP <<EOF || exit 1
292 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
293 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
294 #### 2008 Free Software Foundation, Inc.
302 TMP=$TMP_BASE-blank-lines
304 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
306 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
307 #2008 Free Software Foundation, Inc.
309 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
311 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
312 2008 Free Software Foundation, Inc.
314 UPDATE_COPYRIGHT_YEAR=2010 \
315 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
316 compare /dev/null $TMP-stdout || exit 1
317 compare - $TMP-stderr <<EOF || exit 1
318 $TMP: warning: FSF copyright statement not found
320 compare - $TMP <<EOF || exit 1
321 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
323 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
324 #2008 Free Software Foundation, Inc.
326 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
328 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
329 2008 Free Software Foundation, Inc.
337 TMP=$TMP_BASE-leading-tabs
339 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
340 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
341 Software Foundation, Inc.
343 UPDATE_COPYRIGHT_YEAR=2010 \
344 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
345 compare /dev/null $TMP-stdout || exit 1
346 compare /dev/null $TMP-stderr || exit 1
347 compare - $TMP <<EOF || exit 1
348 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996,
349 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
350 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
352 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
353 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
354 compare /dev/null $TMP-stdout || exit 1
355 compare /dev/null $TMP-stderr || exit 1
356 compare - $TMP <<EOF || exit 1
357 Copyright (C) 1987-1988, 1991-2011 Free Software Foundation,
362 ## -------------------- ##
363 ## Unusual whitespace. ##
364 ## -------------------- ##
366 TMP=$TMP_BASE-unusual-ws
368 # Copyright (C) 87-88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
369 # 98, 1999, 2000, 2001, 2002, 2003,
\f 2004, 2005, 2006, 2007, 2008,
370 # 2009 Free Software Foundation, Inc.
372 UPDATE_COPYRIGHT_YEAR=2010 \
373 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
374 compare /dev/null $TMP-stdout || exit 1
375 compare /dev/null $TMP-stderr || exit 1
376 compare - $TMP <<EOF || exit 1
377 # Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994,
378 # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
379 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
382 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
383 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
384 compare /dev/null $TMP-stdout || exit 1
385 compare /dev/null $TMP-stderr || exit 1
386 compare - $TMP <<EOF || exit 1
387 # Copyright (C) 1987-1988, 1991-2011 Free Software
396 TMP=$TMP_BASE-dos-eol
397 tr @ '\015' > $TMP <<\EOF
398 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
399 Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
400 Rem 2009 Free Software Foundation, Inc.@
402 UPDATE_COPYRIGHT_YEAR=2010 \
403 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
404 compare /dev/null $TMP-stdout || exit 1
405 compare /dev/null $TMP-stderr || exit 1
406 tr @ '\015' > $TMP-exp <<\EOF
407 Rem Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
408 Rem 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
409 Rem 2009, 2010 Free Software Foundation, Inc.@
411 compare $TMP-exp $TMP || exit 1
414 ## --------------- ##
416 ## --------------- ##
418 TMP=$TMP_BASE-omitted-circle-c
420 Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
421 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
422 2009 Free Software Foundation, Inc.
424 UPDATE_COPYRIGHT_YEAR=2010 \
425 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
426 compare /dev/null $TMP-stdout || exit 1
427 compare /dev/null $TMP-stderr || exit 1
428 compare - $TMP <<EOF || exit 1
429 Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
430 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
431 Free Software Foundation, Inc.
435 ## ------------------ ##
436 ## C-style comments. ##
437 ## ------------------ ##
439 TMP=$TMP_BASE-c-style-comments
440 cat > $TMP.star <<EOF
441 /* Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
442 * 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
443 * 2009 Free Software Foundation, Inc. */
445 cat > $TMP.space <<EOF
446 /*Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
447 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
448 2009 Free Software Foundation, Inc. */
450 cat > $TMP.single-line <<EOF
451 /* Copyright 87, 1991, 1992 Free Software Foundation, Inc. */
453 cat > $TMP.single-line-wrapped <<EOF
454 /* Copyright 1988, 1991, 1992, 1993 Free Software Foundation, Inc. */
456 cat > $TMP.extra-text-star <<EOF
457 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. End
460 cat > $TMP.extra-text-space <<EOF
461 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. ***
462 * End of comments. */
464 UPDATE_COPYRIGHT_YEAR=2010 \
465 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
466 compare /dev/null $TMP-stdout || exit 1
467 compare /dev/null $TMP-stderr || exit 1
468 compare - $TMP.star <<EOF || exit 1
469 /* Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
470 * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
471 * 2009, 2010 Free Software Foundation, Inc. */
473 compare - $TMP.space <<EOF || exit 1
474 /*Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
475 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
476 2009, 2010 Free Software Foundation, Inc. */
478 compare - $TMP.single-line <<EOF || exit 1
479 /* Copyright 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */
481 compare - $TMP.single-line-wrapped <<EOF || exit 1
482 /* Copyright 1988, 1991, 1992, 1993, 2010 Free Software Foundation,
485 compare - $TMP.extra-text-star <<EOF || exit 1
486 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
490 compare - $TMP.extra-text-space <<EOF || exit 1
491 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
493 * End of comments. */