2 # Test suite for update-copyright.
3 # Copyright (C) 2009-2019 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 <https://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 # Ensure the update-copyright program gets found.
27 PATH
=$abs_aux_dir:$PATH
30 TMP_BASE
=update-copyright.
test
31 trap 'rm -f $TMP_BASE*' 0 1 2 3 15
33 ## --------------------------------- ##
34 ## Skip if user does not have perl. ##
35 ## --------------------------------- ##
40 eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" "$@"'
41 & eval 'exec perl -wS -0777 -pi "$0" $argv:q'
47 .
/$s $TMP-in 2>/dev
/null
&& test b
= "`cat $TMP-in 2>/dev/null`" ||
49 printf '%s\n' "$0: skipping this test;" \
50 'your system has insufficient support for Perl' 1>&2
54 # Skip this test if Perl is too old. FIXME: 5.8.0 is just a guess.
55 # We have a report that 5.6.1 is inadequate and that 5.8.0 works.
56 perl
-e 'require 5.8.0' ||
{
57 echo '$0: skipping this test; Perl version is too old' 1>&2
61 # Do not let a different envvar setting perturb results.
62 UPDATE_COPYRIGHT_MAX_LINE_LENGTH
=72
63 export UPDATE_COPYRIGHT_MAX_LINE_LENGTH
65 ## ----------------------------- ##
66 ## Examples from documentation. ##
67 ## ----------------------------- ##
71 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
75 # Copyright (C) 1990-2005, 2007-2009 Free Software
80 * Copyright © 90,2005,2007-2009
81 * Free Software Foundation, Inc.
85 ## Copyright (C) 1990-2005, 2007-2009 Free Software
89 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
92 ## Copyright (C) 1990-2005, 2007-2009 Free Software
95 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
99 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
101 # Copyright (C) 1990-2005, 2007-2009 Free Software
105 UPDATE_COPYRIGHT_YEAR
=2009 \
106 update-copyright
$TMP.?
1> $TMP-stdout 2> $TMP-stderr
107 compare
/dev
/null
$TMP-stdout ||
exit 1
108 compare
- $TMP-stderr <<EOF || exit 1
109 $TMP.4: warning: copyright statement not found
110 $TMP.5: warning: copyright statement not found
112 compare
- $TMP.1 <<EOF || exit 1
113 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
116 compare
- $TMP.2 <<EOF || exit 1
117 # Copyright (C) 1990-2005, 2007-2009 Free Software
120 compare
- $TMP.3 <<EOF || exit 1
122 * Copyright © 90,2005,2007-2009
123 * Free Software Foundation, Inc.
126 compare
- $TMP.4 <<EOF || exit 1
127 ## Copyright (C) 1990-2005, 2007-2009 Free Software
130 compare
- $TMP.5 <<EOF || exit 1
131 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
133 compare
- $TMP.6 <<EOF || exit 1
134 ## Copyright (C) 1990-2005, 2007-2009 Free Software
137 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
140 compare
- $TMP.7 <<EOF || exit 1
141 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
143 # Copyright (C) 1990-2005, 2007-2009 Free Software
147 UPDATE_COPYRIGHT_YEAR
=2010 UPDATE_COPYRIGHT_USE_INTERVALS
=1 \
148 update-copyright
$TMP.?
1> $TMP-stdout 2> $TMP-stderr
149 compare
/dev
/null
$TMP-stdout ||
exit 1
150 compare
- $TMP-stderr <<EOF || exit 1
151 $TMP.4: warning: copyright statement not found
152 $TMP.5: warning: copyright statement not found
154 compare
- $TMP.1 <<EOF || exit 1
155 Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation,
158 compare
- $TMP.2 <<EOF || exit 1
159 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
161 compare
- $TMP.3 <<EOF || exit 1
163 * Copyright © 1990, 2005, 2007-2010 Free Software Foundation, Inc.
166 compare
- $TMP.4 <<EOF || exit 1
167 ## Copyright (C) 1990-2005, 2007-2009 Free Software
170 compare
- $TMP.5 <<EOF || exit 1
171 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
173 compare
- $TMP.6 <<EOF || exit 1
174 ## Copyright (C) 1990-2005, 2007-2009 Free Software
177 Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
179 compare
- $TMP.7 <<EOF || exit 1
180 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
182 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
185 UPDATE_COPYRIGHT_YEAR
=2010 UPDATE_COPYRIGHT_FORCE
=1 \
186 update-copyright
$TMP.?
1> $TMP-stdout 2> $TMP-stderr
187 compare
/dev
/null
$TMP-stdout ||
exit 1
188 compare
- $TMP-stderr <<EOF || exit 1
189 $TMP.4: warning: copyright statement not found
190 $TMP.5: warning: copyright statement not found
192 compare
- $TMP.1 <<EOF || exit 1
193 Copyright @copyright{} 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
194 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
195 Free Software Foundation, Inc.
197 compare
- $TMP.2 <<EOF || exit 1
198 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
199 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
200 # Software Foundation, Inc.
202 compare
- $TMP.3 <<EOF || exit 1
204 * Copyright © 1990, 2005, 2007, 2008, 2009, 2010 Free Software
208 compare
- $TMP.4 <<EOF || exit 1
209 ## Copyright (C) 1990-2005, 2007-2009 Free Software
212 compare
- $TMP.5 <<EOF || exit 1
213 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
215 compare
- $TMP.6 <<EOF || exit 1
216 ## Copyright (C) 1990-2005, 2007-2009 Free Software
219 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
220 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
221 Software Foundation, Inc.
223 compare
- $TMP.7 <<EOF || exit 1
224 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
226 # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
227 # 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
228 # Software Foundation, Inc.
237 TMP
=$TMP_BASE-current-year
240 '\" Copyright (C) 2006
241 '\" Free Software Foundation,
244 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
245 compare
/dev
/null
$TMP-stdout ||
exit 1
246 compare
/dev
/null
$TMP-stderr ||
exit 1
247 compare
- $TMP <<EOF || exit 1
248 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
250 UPDATE_COPYRIGHT_USE_INTERVALS
=1 \
251 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
252 compare
/dev
/null
$TMP-stdout ||
exit 1
253 compare
/dev
/null
$TMP-stderr ||
exit 1
254 compare
- $TMP <<EOF || exit 1
255 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
259 ## ------------------ ##
260 ## Surrounding text. ##
261 ## ------------------ ##
263 TMP
=$TMP_BASE-surrounding-text
266 dnl Undisturbed text.
268 dnl Free Software Foundation, Inc.
269 dnl Undisturbed text.
271 UPDATE_COPYRIGHT_YEAR
=2010 \
272 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
273 compare
/dev
/null
$TMP-stdout ||
exit 1
274 compare
/dev
/null
$TMP-stderr ||
exit 1
275 compare
- $TMP <<EOF || exit 1
277 dnl Undisturbed text.
278 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
279 dnl Undisturbed text.
283 ## --------------- ##
285 ## --------------- ##
287 TMP
=$TMP_BASE-widest-prefix
289 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
290 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
291 #### 2008 Free Software Foundation, Inc.
293 UPDATE_COPYRIGHT_YEAR
=2010 \
294 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
295 compare
/dev
/null
$TMP-stdout ||
exit 1
296 compare
/dev
/null
$TMP-stderr ||
exit 1
297 compare
- $TMP <<EOF || exit 1
298 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
299 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
300 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
302 UPDATE_COPYRIGHT_YEAR
=2011 UPDATE_COPYRIGHT_USE_INTERVALS
=1 \
303 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
304 compare
/dev
/null
$TMP-stdout ||
exit 1
305 compare
/dev
/null
$TMP-stderr ||
exit 1
306 compare
- $TMP <<EOF || exit 1
307 #### Copyright (C) 1976-1988, 1999-2008, 2010-2011 Free Software
308 #### Foundation, Inc.
312 ## ------------------- ##
313 ## Prefix too large. ##
314 ## ------------------- ##
316 TMP
=$TMP_BASE-prefix-too-large
318 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
319 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
320 #### 2008 Free Software Foundation, Inc.
322 UPDATE_COPYRIGHT_YEAR
=2010 \
323 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
324 compare
/dev
/null
$TMP-stdout ||
exit 1
325 compare
- $TMP-stderr <<EOF || exit 1
326 $TMP: warning: copyright statement not found
328 compare
- $TMP <<EOF || exit 1
329 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
330 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
331 #### 2008 Free Software Foundation, Inc.
339 TMP
=$TMP_BASE-blank-lines
341 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
343 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
344 #2008 Free Software Foundation, Inc.
346 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
348 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
349 2008 Free Software Foundation, Inc.
351 UPDATE_COPYRIGHT_YEAR
=2010 \
352 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
353 compare
/dev
/null
$TMP-stdout ||
exit 1
354 compare
- $TMP-stderr <<EOF || exit 1
355 $TMP: warning: copyright statement not found
357 compare
- $TMP <<EOF || exit 1
358 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
360 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
361 #2008 Free Software Foundation, Inc.
363 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
365 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
366 2008 Free Software Foundation, Inc.
374 TMP
=$TMP_BASE-leading-tabs
376 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
377 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
378 Software Foundation, Inc.
380 UPDATE_COPYRIGHT_YEAR
=2010 \
381 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
382 compare
/dev
/null
$TMP-stdout ||
exit 1
383 compare
/dev
/null
$TMP-stderr ||
exit 1
384 compare
- $TMP <<EOF || exit 1
385 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996,
386 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
387 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
389 UPDATE_COPYRIGHT_YEAR
=2011 UPDATE_COPYRIGHT_USE_INTERVALS
=1 \
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-2011 Free Software Foundation,
399 ## -------------------- ##
400 ## Unusual whitespace. ##
401 ## -------------------- ##
403 TMP
=$TMP_BASE-unusual-ws
405 # Copyright (C) 87-88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
406 # 98, 1999, 2000, 2001, 2002, 2003, \f 2004, 2005, 2006, 2007, 2008,
407 # 2009 Free Software Foundation, Inc.
409 UPDATE_COPYRIGHT_YEAR
=2010 \
410 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
411 compare
/dev
/null
$TMP-stdout ||
exit 1
412 compare
/dev
/null
$TMP-stderr ||
exit 1
413 compare
- $TMP <<EOF || exit 1
414 # Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994,
415 # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
416 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
419 UPDATE_COPYRIGHT_YEAR
=2011 UPDATE_COPYRIGHT_USE_INTERVALS
=1 \
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 compare
- $TMP <<EOF || exit 1
424 # Copyright (C) 1987-1988, 1991-2011 Free Software
427 UPDATE_COPYRIGHT_YEAR
=2011 UPDATE_COPYRIGHT_USE_INTERVALS
=2 \
428 UPDATE_COPYRIGHT_FORCE
=1 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
429 compare
/dev
/null
$TMP-stdout ||
exit 1
430 compare
/dev
/null
$TMP-stderr ||
exit 1
431 compare
- $TMP <<EOF || exit 1
432 # Copyright (C) 1987-2011 Free Software Foundation, Inc.
440 TMP
=$TMP_BASE-dos-eol
441 tr @
'\015' > $TMP <<\EOF
442 Rem Copyright
(C
) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
443 Rem
98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
444 Rem
2009 Free Software Foundation
, Inc.@
446 UPDATE_COPYRIGHT_YEAR
=2010 \
447 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
448 compare
/dev
/null
$TMP-stdout ||
exit 1
449 compare
/dev
/null
$TMP-stderr ||
exit 1
450 tr @
'\015' > $TMP-exp <<\EOF
451 Rem Copyright
(C
) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
452 Rem
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
453 Rem
2009, 2010 Free Software Foundation
, Inc.@
455 compare
$TMP-exp $TMP ||
exit 1
458 ## --------------- ##
460 ## --------------- ##
462 TMP
=$TMP_BASE-omitted-circle-c
464 Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
465 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
466 2009 Free Software Foundation, Inc.
468 UPDATE_COPYRIGHT_YEAR
=2010 \
469 update-copyright
$TMP 1> $TMP-stdout 2> $TMP-stderr
470 compare
/dev
/null
$TMP-stdout ||
exit 1
471 compare
/dev
/null
$TMP-stderr ||
exit 1
472 compare
- $TMP <<EOF || exit 1
473 Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
474 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
475 Free Software Foundation, Inc.
479 ## ------------------ ##
480 ## C-style comments. ##
481 ## ------------------ ##
483 TMP
=$TMP_BASE-c-style-comments
484 cat > $TMP.star
<<EOF
485 /* Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
486 * 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
487 * 2009 Free Software Foundation, Inc. */
489 cat > $TMP.space
<<EOF
490 /*Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
491 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
492 2009 Free Software Foundation, Inc. */
494 cat > $TMP.single-line
<<EOF
495 /* Copyright 87, 1991, 1992 Free Software Foundation, Inc. */
497 cat > $TMP.single-line-wrapped
<<EOF
498 /* Copyright 1988, 1991, 1992, 1993 Free Software Foundation, Inc. */
500 cat > $TMP.extra-text-star
<<EOF
501 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. End
504 cat > $TMP.extra-text-space
<<EOF
505 /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. ***
506 * End of comments. */
508 cat > $TMP.two-digit-final-is-substr-of-first
<<EOF
509 /* Copyright 1991, 99 Free Software Foundation, Inc. */
511 UPDATE_COPYRIGHT_YEAR
=2010 \
512 update-copyright
$TMP.
* 1> $TMP-stdout 2> $TMP-stderr
513 compare
/dev
/null
$TMP-stdout ||
exit 1
514 compare
/dev
/null
$TMP-stderr ||
exit 1
515 compare
- $TMP.star
<<EOF || exit 1
516 /* Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
517 * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
518 * 2009, 2010 Free Software Foundation, Inc. */
520 compare
- $TMP.space
<<EOF || exit 1
521 /*Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
522 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
523 2009, 2010 Free Software Foundation, Inc. */
525 compare
- $TMP.single-line
<<EOF || exit 1
526 /* Copyright 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */
528 compare
- $TMP.single-line-wrapped
<<EOF || exit 1
529 /* Copyright 1988, 1991, 1992, 1993, 2010 Free Software Foundation,
532 compare
- $TMP.extra-text-star
<<EOF || exit 1
533 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
537 compare
- $TMP.extra-text-space
<<EOF || exit 1
538 /* Copyright 1987, 1988, 1991, 1992, 2010 Free Software Foundation,
540 * End of comments. */
542 compare
- $TMP.two-digit-final-is-substr-of-first
<<EOF || exit 1
543 /* Copyright 1991, 1999, 2010 Free Software Foundation, Inc. */