2 # Test suite for update-copyright.
3 # Copyright (C) 2009-2010 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 # Skip this test if Perl is too old. FIXME: 5.8.0 is just a guess.
20 # We have a report that 5.6.1 is inadequate and that 5.8.0 works.
21 perl -e 'require 5.8.0' || exit 77
23 diffout=`diff -u /dev/null /dev/null 2>&1`
24 if test x"$diffout" = x"" && test $? -eq 0; then
25 compare() { diff -u "$@"; }
27 compare() { cmp "$@"; }
30 # Ensure the update-copyright program gets found.
31 PATH=$abs_aux_dir:$PATH
33 TMP_BASE=update-copyright.test
34 trap 'rm -f $TMP_BASE*' 0 1 2 3 15
36 ## --------------------------------- ##
37 ## Skip if user does not have perl. ##
38 ## --------------------------------- ##
43 eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" ${1+"$@"}'
44 & eval 'exec perl -wS -0777 -pi "$0" $argv:q'
50 ./$s $TMP-in 2>/dev/null && test b = "`cat $TMP-in 2>/dev/null`" ||
52 printf '%s\n' "$0: skipping this test;" \
53 'your system has insufficient support for Perl' 1>&2
57 # Do not let a different envvar setting perturb results.
58 UPDATE_COPYRIGHT_MAX_LINE_LENGTH=72
59 export UPDATE_COPYRIGHT_MAX_LINE_LENGTH
61 ## ----------------------------- ##
62 ## Examples from documentation. ##
63 ## ----------------------------- ##
67 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
71 # Copyright (C) 1990-2005, 2007-2009 Free Software
76 * Copyright © 90,2005,2007-2009
77 * Free Software Foundation, Inc.
81 ## Copyright (C) 1990-2005, 2007-2009 Free Software
85 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
88 ## Copyright (C) 1990-2005, 2007-2009 Free Software
91 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
95 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
97 # Copyright (C) 1990-2005, 2007-2009 Free Software
102 UPDATE_COPYRIGHT_YEAR=2009 \
103 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
104 compare /dev/null $TMP-stdout || exit 1
105 compare - $TMP-stderr <<EOF || exit 1
106 $TMP.4: warning: FSF copyright statement not found
107 $TMP.5: warning: FSF copyright statement not found
109 compare - $TMP.1 <<EOF || exit 1
110 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
113 compare - $TMP.2 <<EOF || exit 1
114 # Copyright (C) 1990-2005, 2007-2009 Free Software
117 compare - $TMP.3 <<EOF || exit 1
119 * Copyright © 90,2005,2007-2009
120 * Free Software Foundation, Inc.
123 compare - $TMP.4 <<EOF || exit 1
124 ## Copyright (C) 1990-2005, 2007-2009 Free Software
127 compare - $TMP.5 <<EOF || exit 1
128 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
130 compare - $TMP.6 <<EOF || exit 1
131 ## Copyright (C) 1990-2005, 2007-2009 Free Software
134 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
137 compare - $TMP.7 <<EOF || exit 1
138 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
140 # Copyright (C) 1990-2005, 2007-2009 Free Software
145 UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
146 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
147 compare /dev/null $TMP-stdout || exit 1
148 compare - $TMP-stderr <<EOF || exit 1
149 $TMP.4: warning: FSF copyright statement not found
150 $TMP.5: warning: FSF copyright statement not found
152 compare - $TMP.1 <<EOF || exit 1
153 Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation,
156 compare - $TMP.2 <<EOF || exit 1
157 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
159 compare - $TMP.3 <<EOF || exit 1
161 * Copyright © 1990, 2005, 2007-2010 Free Software Foundation, Inc.
164 compare - $TMP.4 <<EOF || exit 1
165 ## Copyright (C) 1990-2005, 2007-2009 Free Software
168 compare - $TMP.5 <<EOF || exit 1
169 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
171 compare - $TMP.6 <<EOF || exit 1
172 ## Copyright (C) 1990-2005, 2007-2009 Free Software
175 Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
177 compare - $TMP.7 <<EOF || exit 1
178 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
180 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
184 UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_FORCE=1 \
185 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
186 compare /dev/null $TMP-stdout || exit 1
187 compare - $TMP-stderr <<EOF || exit 1
188 $TMP.4: warning: FSF copyright statement not found
189 $TMP.5: warning: FSF copyright statement not found
191 compare - $TMP.1 <<EOF || exit 1
192 Copyright @copyright{} 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
193 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
194 Free Software Foundation, Inc.
196 compare - $TMP.2 <<EOF || exit 1
197 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
198 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
199 # Software Foundation, Inc.
201 compare - $TMP.3 <<EOF || exit 1
203 * Copyright © 1990, 2005, 2007, 2008, 2009, 2010 Free Software
207 compare - $TMP.4 <<EOF || exit 1
208 ## Copyright (C) 1990-2005, 2007-2009 Free Software
211 compare - $TMP.5 <<EOF || exit 1
212 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
214 compare - $TMP.6 <<EOF || exit 1
215 ## Copyright (C) 1990-2005, 2007-2009 Free Software
218 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
219 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
220 Software Foundation, Inc.
222 compare - $TMP.7 <<EOF || exit 1
223 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
225 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
226 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
227 # Software Foundation, Inc.
236 TMP=$TMP_BASE-current-year
239 '\" Copyright (C) 2006
240 '\" Free Software Foundation,
243 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
244 compare /dev/null $TMP-stdout || exit 1
245 compare /dev/null $TMP-stderr || exit 1
246 compare - $TMP <<EOF || exit 1
247 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
249 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
250 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
251 compare /dev/null $TMP-stdout || exit 1
252 compare /dev/null $TMP-stderr || exit 1
253 compare - $TMP <<EOF || exit 1
254 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
258 ## ------------------ ##
259 ## Surrounding text. ##
260 ## ------------------ ##
262 TMP=$TMP_BASE-surrounding-text
265 dnl Undisturbed text.
267 dnl Free Software Foundation, Inc.
268 dnl Undisturbed text.
270 UPDATE_COPYRIGHT_YEAR=2010 \
271 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
272 compare /dev/null $TMP-stdout || exit 1
273 compare /dev/null $TMP-stderr || exit 1
274 compare - $TMP <<EOF || exit 1
276 dnl Undisturbed text.
277 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
278 dnl Undisturbed text.
282 ## --------------- ##
284 ## --------------- ##
286 TMP=$TMP_BASE-widest-prefix
288 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
289 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
290 #### 2008 Free Software Foundation, Inc.
292 UPDATE_COPYRIGHT_YEAR=2010 \
293 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
294 compare /dev/null $TMP-stdout || exit 1
295 compare /dev/null $TMP-stderr || exit 1
296 compare - $TMP <<EOF || exit 1
297 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
298 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
299 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
301 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
302 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
303 compare /dev/null $TMP-stdout || exit 1
304 compare /dev/null $TMP-stderr || exit 1
305 compare - $TMP <<EOF || exit 1
306 #### Copyright (C) 1976-1988, 1999-2008, 2010-2011 Free Software
307 #### Foundation, Inc.
311 ## ------------------- ##
312 ## Prefix too large. ##
313 ## ------------------- ##
315 TMP=$TMP_BASE-prefix-too-large
317 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
318 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
319 #### 2008 Free Software Foundation, Inc.
321 UPDATE_COPYRIGHT_YEAR=2010 \
322 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
323 compare /dev/null $TMP-stdout || exit 1
324 compare - $TMP-stderr <<EOF || exit 1
325 $TMP: warning: FSF copyright statement not found
327 compare - $TMP <<EOF || exit 1
328 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
329 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
330 #### 2008 Free Software Foundation, Inc.
338 TMP=$TMP_BASE-blank-lines
340 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
342 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
343 #2008 Free Software Foundation, Inc.
345 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
347 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
348 2008 Free Software Foundation, Inc.
350 UPDATE_COPYRIGHT_YEAR=2010 \
351 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
352 compare /dev/null $TMP-stdout || exit 1
353 compare - $TMP-stderr <<EOF || exit 1
354 $TMP: warning: FSF copyright statement not found
356 compare - $TMP <<EOF || exit 1
357 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
359 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
360 #2008 Free Software Foundation, Inc.
362 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
364 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
365 2008 Free Software Foundation, Inc.
373 TMP=$TMP_BASE-leading-tabs
375 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
376 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
377 Software Foundation, Inc.
379 UPDATE_COPYRIGHT_YEAR=2010 \
380 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
381 compare /dev/null $TMP-stdout || exit 1
382 compare /dev/null $TMP-stderr || exit 1
383 compare - $TMP <<EOF || exit 1
384 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996,
385 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
386 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
388 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
389 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
390 compare /dev/null $TMP-stdout || exit 1
391 compare /dev/null $TMP-stderr || exit 1
392 compare - $TMP <<EOF || exit 1
393 Copyright (C) 1987-1988, 1991-2011 Free Software Foundation,
398 ## -------------------- ##
399 ## Unusual whitespace. ##
400 ## -------------------- ##
402 TMP=$TMP_BASE-unusual-ws
404 # Copyright (C) 87-88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
405 # 98, 1999, 2000, 2001, 2002, 2003,
\f 2004, 2005, 2006, 2007, 2008,
406 # 2009 Free Software Foundation, Inc.
408 UPDATE_COPYRIGHT_YEAR=2010 \
409 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
410 compare /dev/null $TMP-stdout || exit 1
411 compare /dev/null $TMP-stderr || exit 1
412 compare - $TMP <<EOF || exit 1
413 # Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994,
414 # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
415 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
418 UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
419 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
420 compare /dev/null $TMP-stdout || exit 1
421 compare /dev/null $TMP-stderr || exit 1
422 compare - $TMP <<EOF || exit 1
423 # Copyright (C) 1987-1988, 1991-2011 Free Software
432 TMP=$TMP_BASE-dos-eol
433 tr @ '\015' > $TMP <<\EOF
434 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
435 Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
436 Rem 2009 Free Software Foundation, Inc.@
438 UPDATE_COPYRIGHT_YEAR=2010 \
439 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
440 compare /dev/null $TMP-stdout || exit 1
441 compare /dev/null $TMP-stderr || exit 1
442 tr @ '\015' > $TMP-exp <<\EOF
443 Rem Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
444 Rem 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
445 Rem 2009, 2010 Free Software Foundation, Inc.@
447 compare $TMP-exp $TMP || exit 1
450 ## --------------- ##
452 ## --------------- ##
454 TMP=$TMP_BASE-omitted-circle-c
456 Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
457 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
458 2009 Free Software Foundation, Inc.
460 UPDATE_COPYRIGHT_YEAR=2010 \
461 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
462 compare /dev/null $TMP-stdout || exit 1
463 compare /dev/null $TMP-stderr || exit 1
464 compare - $TMP <<EOF || exit 1
465 Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
466 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
467 Free Software Foundation, Inc.
471 ## ------------------ ##
472 ## C-style comments. ##
473 ## ------------------ ##
475 TMP=$TMP_BASE-c-style-comments
476 cat > $TMP.star <<EOF
477 /* Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
478 * 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
479 * 2009 Free Software Foundation, Inc. */
481 cat > $TMP.space <<EOF
482 /*Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
483 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
484 2009 Free Software Foundation, Inc. */
486 cat > $TMP.single-line <<EOF
487 /* Copyright 87, 1991, 1992 Free Software Foundation, Inc. */
489 cat > $TMP.single-line-wrapped <<EOF
490 /* Copyright 1988, 1991, 1992, 1993 Free Software Foundation, Inc. */
492 cat > $TMP.extra-text-star <<EOF
493 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. End
496 cat > $TMP.extra-text-space <<EOF
497 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. ***
498 * End of comments. */
500 UPDATE_COPYRIGHT_YEAR=2010 \
501 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
502 compare /dev/null $TMP-stdout || exit 1
503 compare /dev/null $TMP-stderr || exit 1
504 compare - $TMP.star <<EOF || exit 1
505 /* Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
506 * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
507 * 2009, 2010 Free Software Foundation, Inc. */
509 compare - $TMP.space <<EOF || exit 1
510 /*Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
511 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
512 2009, 2010 Free Software Foundation, Inc. */
514 compare - $TMP.single-line <<EOF || exit 1
515 /* Copyright 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */
517 compare - $TMP.single-line-wrapped <<EOF || exit 1
518 /* Copyright 1988, 1991, 1992, 1993, 2010 Free Software Foundation,
521 compare - $TMP.extra-text-star <<EOF || exit 1
522 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
526 compare - $TMP.extra-text-space <<EOF || exit 1
527 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
529 * End of comments. */