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
27 trap 'rm -f $TMP_BASE*' 0 1 2 3 15
29 ## --------------------------------- ##
30 ## Skip if user does not have perl. ##
31 ## --------------------------------- ##
35 printf '#!/usr/bin/perl -pi\ns/a/b/\n' > $s
38 ./$s $TMP-in 2>/dev/null && test b = "`cat $TMP-in 2>/dev/null`" ||
40 printf '%s\n' "$0: skipping this test;" \
41 'your system has insufficient support for Perl' 1>&2
45 ## ----------------------------- ##
46 ## Examples from documentation. ##
47 ## ----------------------------- ##
51 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
55 # Copyright (C) 1990-2005, 2007-2009 Free Software
60 * Copyright © 90,2005,2007-2009
61 * Free Software Foundation, Inc.
65 ## Copyright (C) 1990-2005, 2007-2009 Free Software
69 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
72 ## Copyright (C) 1990-2005, 2007-2009 Free Software
75 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
79 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
81 # Copyright (C) 1990-2005, 2007-2009 Free Software
85 UPDATE_COPYRIGHT_YEAR=2009 \
86 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
87 compare /dev/null $TMP-stdout || exit 1
88 compare - $TMP-stderr <<EOF || exit 1
89 $TMP.4: warning: FSF copyright statement not found
90 $TMP.5: warning: FSF copyright statement not found
92 compare - $TMP.1 <<EOF || exit 1
93 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
96 compare - $TMP.2 <<EOF || exit 1
97 # Copyright (C) 1990-2005, 2007-2009 Free Software
100 compare - $TMP.3 <<EOF || exit 1
102 * Copyright © 90,2005,2007-2009
103 * Free Software Foundation, Inc.
106 compare - $TMP.4 <<EOF || exit 1
107 ## Copyright (C) 1990-2005, 2007-2009 Free Software
110 compare - $TMP.5 <<EOF || exit 1
111 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
113 compare - $TMP.6 <<EOF || exit 1
114 ## Copyright (C) 1990-2005, 2007-2009 Free Software
117 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
120 compare - $TMP.7 <<EOF || exit 1
121 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
123 # Copyright (C) 1990-2005, 2007-2009 Free Software
127 UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
128 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
129 compare /dev/null $TMP-stdout || exit 1
130 compare - $TMP-stderr <<EOF || exit 1
131 $TMP.4: warning: FSF copyright statement not found
132 $TMP.5: warning: FSF copyright statement not found
134 compare - $TMP.1 <<EOF || exit 1
135 Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation,
138 compare - $TMP.2 <<EOF || exit 1
139 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
141 compare - $TMP.3 <<EOF || exit 1
143 * Copyright © 1990, 2005, 2007-2010 Free Software Foundation, Inc.
146 compare - $TMP.4 <<EOF || exit 1
147 ## Copyright (C) 1990-2005, 2007-2009 Free Software
150 compare - $TMP.5 <<EOF || exit 1
151 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
153 compare - $TMP.6 <<EOF || exit 1
154 ## Copyright (C) 1990-2005, 2007-2009 Free Software
157 Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
159 compare - $TMP.7 <<EOF || exit 1
160 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
162 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
165 UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_FORCE=1 \
166 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
167 compare /dev/null $TMP-stdout || exit 1
168 compare - $TMP-stderr <<EOF || exit 1
169 $TMP.4: warning: FSF copyright statement not found
170 $TMP.5: warning: FSF copyright statement not found
172 compare - $TMP.1 <<EOF || exit 1
173 Copyright @copyright{} 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
174 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
175 Free Software Foundation, Inc.
177 compare - $TMP.2 <<EOF || exit 1
178 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
179 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
180 # Software Foundation, Inc.
182 compare - $TMP.3 <<EOF || exit 1
184 * Copyright © 1990, 2005, 2007, 2008, 2009, 2010 Free Software
188 compare - $TMP.4 <<EOF || exit 1
189 ## Copyright (C) 1990-2005, 2007-2009 Free Software
192 compare - $TMP.5 <<EOF || exit 1
193 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
195 compare - $TMP.6 <<EOF || exit 1
196 ## Copyright (C) 1990-2005, 2007-2009 Free Software
199 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
200 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
201 Software Foundation, Inc.
203 compare - $TMP.7 <<EOF || exit 1
204 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
206 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
207 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
208 # Software Foundation, Inc.
217 TMP=$TMP_BASE-current-year
218 YEAR=`/usr/bin/perl -e 'print [localtime]->[5] + 1900'`;
220 '\" Copyright (C) 2006
221 '\" Free Software Foundation,
224 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
225 compare /dev/null $TMP-stdout || exit 1
226 compare /dev/null $TMP-stderr || exit 1
227 compare - $TMP <<EOF || exit 1
228 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
230 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
231 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
232 compare /dev/null $TMP-stdout || exit 1
233 compare /dev/null $TMP-stderr || exit 1
234 compare - $TMP <<EOF || exit 1
235 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
239 ## ------------------ ##
240 ## Surrounding text. ##
241 ## ------------------ ##
243 TMP=$TMP_BASE-surrounding-text
246 dnl Undisturbed text.
248 dnl Free Software Foundation, Inc.
249 dnl Undisturbed text.
251 UPDATE_COPYRIGHT_YEAR=2010 \
252 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
253 compare /dev/null $TMP-stdout || exit 1
254 compare /dev/null $TMP-stderr || exit 1
255 compare - $TMP <<EOF || exit 1
257 dnl Undisturbed text.
258 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
259 dnl Undisturbed text.
263 ## --------------- ##
265 ## --------------- ##
267 TMP=$TMP_BASE-widest-prefix
269 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
270 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
271 #### 2008 Free Software Foundation, Inc.
273 UPDATE_COPYRIGHT_YEAR=2010 \
274 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
275 compare /dev/null $TMP-stdout || exit 1
276 compare /dev/null $TMP-stderr || exit 1
277 compare - $TMP <<EOF || exit 1
278 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
279 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
280 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
282 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
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) 1976-1988, 1999-2008, 2010-2011 Free Software
288 #### Foundation, Inc.
292 ## ------------------- ##
293 ## Prefix too large. ##
294 ## ------------------- ##
296 TMP=$TMP_BASE-prefix-too-large
298 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
299 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
300 #### 2008 Free Software Foundation, Inc.
302 UPDATE_COPYRIGHT_YEAR=2010 \
303 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
304 compare /dev/null $TMP-stdout || exit 1
305 compare - $TMP-stderr <<EOF || exit 1
306 $TMP: warning: FSF copyright statement not found
308 compare - $TMP <<EOF || exit 1
309 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
310 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
311 #### 2008 Free Software Foundation, Inc.
319 TMP=$TMP_BASE-blank-lines
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.
331 UPDATE_COPYRIGHT_YEAR=2010 \
332 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
333 compare /dev/null $TMP-stdout || exit 1
334 compare - $TMP-stderr <<EOF || exit 1
335 $TMP: warning: FSF copyright statement not found
337 compare - $TMP <<EOF || exit 1
338 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
340 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
341 #2008 Free Software Foundation, Inc.
343 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
345 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
346 2008 Free Software Foundation, Inc.
354 TMP=$TMP_BASE-leading-tabs
356 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
357 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
358 Software Foundation, Inc.
360 UPDATE_COPYRIGHT_YEAR=2010 \
361 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
362 compare /dev/null $TMP-stdout || exit 1
363 compare /dev/null $TMP-stderr || exit 1
364 compare - $TMP <<EOF || exit 1
365 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996,
366 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
367 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
369 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
370 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
371 compare /dev/null $TMP-stdout || exit 1
372 compare /dev/null $TMP-stderr || exit 1
373 compare - $TMP <<EOF || exit 1
374 Copyright (C) 1987-1988, 1991-2011 Free Software Foundation,
379 ## -------------------- ##
380 ## Unusual whitespace. ##
381 ## -------------------- ##
383 TMP=$TMP_BASE-unusual-ws
385 # Copyright (C) 87-88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
386 # 98, 1999, 2000, 2001, 2002, 2003,
\f 2004, 2005, 2006, 2007, 2008,
387 # 2009 Free Software Foundation, Inc.
389 UPDATE_COPYRIGHT_YEAR=2010 \
390 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
391 compare /dev/null $TMP-stdout || exit 1
392 compare /dev/null $TMP-stderr || exit 1
393 compare - $TMP <<EOF || exit 1
394 # Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994,
395 # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
396 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
399 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
400 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
401 compare /dev/null $TMP-stdout || exit 1
402 compare /dev/null $TMP-stderr || exit 1
403 compare - $TMP <<EOF || exit 1
404 # Copyright (C) 1987-1988, 1991-2011 Free Software
413 TMP=$TMP_BASE-dos-eol
414 tr @ '\015' > $TMP <<\EOF
415 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
416 Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
417 Rem 2009 Free Software Foundation, Inc.@
419 UPDATE_COPYRIGHT_YEAR=2010 \
420 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
421 compare /dev/null $TMP-stdout || exit 1
422 compare /dev/null $TMP-stderr || exit 1
423 tr @ '\015' > $TMP-exp <<\EOF
424 Rem Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
425 Rem 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
426 Rem 2009, 2010 Free Software Foundation, Inc.@
428 compare $TMP-exp $TMP || exit 1
431 ## --------------- ##
433 ## --------------- ##
435 TMP=$TMP_BASE-omitted-circle-c
437 Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
438 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
439 2009 Free Software Foundation, Inc.
441 UPDATE_COPYRIGHT_YEAR=2010 \
442 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
443 compare /dev/null $TMP-stdout || exit 1
444 compare /dev/null $TMP-stderr || exit 1
445 compare - $TMP <<EOF || exit 1
446 Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
447 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
448 Free Software Foundation, Inc.
452 ## ------------------ ##
453 ## C-style comments. ##
454 ## ------------------ ##
456 TMP=$TMP_BASE-c-style-comments
457 cat > $TMP.star <<EOF
458 /* Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
459 * 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
460 * 2009 Free Software Foundation, Inc. */
462 cat > $TMP.space <<EOF
463 /*Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
464 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
465 2009 Free Software Foundation, Inc. */
467 cat > $TMP.single-line <<EOF
468 /* Copyright 87, 1991, 1992 Free Software Foundation, Inc. */
470 cat > $TMP.single-line-wrapped <<EOF
471 /* Copyright 1988, 1991, 1992, 1993 Free Software Foundation, Inc. */
473 cat > $TMP.extra-text-star <<EOF
474 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. End
477 cat > $TMP.extra-text-space <<EOF
478 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. ***
479 * End of comments. */
481 UPDATE_COPYRIGHT_YEAR=2010 \
482 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
483 compare /dev/null $TMP-stdout || exit 1
484 compare /dev/null $TMP-stderr || exit 1
485 compare - $TMP.star <<EOF || exit 1
486 /* Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
487 * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
488 * 2009, 2010 Free Software Foundation, Inc. */
490 compare - $TMP.space <<EOF || exit 1
491 /*Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
492 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
493 2009, 2010 Free Software Foundation, Inc. */
495 compare - $TMP.single-line <<EOF || exit 1
496 /* Copyright 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */
498 compare - $TMP.single-line-wrapped <<EOF || exit 1
499 /* Copyright 1988, 1991, 1992, 1993, 2010 Free Software Foundation,
502 compare - $TMP.extra-text-star <<EOF || exit 1
503 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
507 compare - $TMP.extra-text-space <<EOF || exit 1
508 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
510 * End of comments. */