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
51 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
55 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
57 # Copyright (C) 1990-2005, 2007-2009 Free Software
61 UPDATE_COPYRIGHT_YEAR=2009 \
62 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
63 compare /dev/null $TMP-stdout || exit 1
64 compare - $TMP-stderr <<EOF || exit 1
65 $TMP.4: warning: FSF copyright statement not found
66 $TMP.5: warning: FSF copyright statement not found
68 compare - $TMP.1 <<EOF || exit 1
69 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
72 compare - $TMP.2 <<EOF || exit 1
73 # Copyright (C) 1990-2005, 2007-2009 Free Software
76 compare - $TMP.3 <<EOF || exit 1
78 * Copyright © 90,2005,2007-2009
79 * Free Software Foundation, Inc.
82 compare - $TMP.4 <<EOF || exit 1
83 /* Copyright (C) 1990-2005, 2007-2009 Free Software
86 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
89 compare - $TMP.5 <<EOF || exit 1
90 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
92 # Copyright (C) 1990-2005, 2007-2009 Free Software
96 UPDATE_COPYRIGHT_YEAR=2010 \
97 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
98 compare /dev/null $TMP-stdout || exit 1
99 compare - $TMP-stderr <<EOF || exit 1
100 $TMP.4: warning: FSF copyright statement not found
101 $TMP.5: warning: FSF copyright statement not found
103 compare - $TMP.1 <<EOF || exit 1
104 Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation,
107 compare - $TMP.2 <<EOF || exit 1
108 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
110 compare - $TMP.3 <<EOF || exit 1
112 * Copyright © 90, 2005, 2007-2010 Free Software Foundation, Inc.
115 compare - $TMP.4 <<EOF || exit 1
116 /* Copyright (C) 1990-2005, 2007-2009 Free Software
117 * Foundation, Inc. */
119 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
122 compare - $TMP.5 <<EOF || exit 1
123 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
125 # Copyright (C) 1990-2005, 2007-2009 Free Software
135 TMP=$TMP_BASE-current-year
136 YEAR=`/usr/bin/perl -e 'print [localtime]->[5] + 1900'`;
138 '\" Copyright (C) 2006
139 '\" Free Software Foundation,
142 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
143 compare /dev/null $TMP-stdout || exit 1
144 compare /dev/null $TMP-stderr || exit 1
145 compare - $TMP <<EOF || exit 1
146 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
150 ## ------------------ ##
151 ## Surrounding text. ##
152 ## ------------------ ##
154 TMP=$TMP_BASE-surrounding-text
157 dnl Undisturbed text.
159 dnl Free Software Foundation, Inc.
160 dnl Undisturbed text.
162 UPDATE_COPYRIGHT_YEAR=2010 \
163 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
164 compare /dev/null $TMP-stdout || exit 1
165 compare /dev/null $TMP-stderr || exit 1
166 compare - $TMP <<EOF || exit 1
168 dnl Undisturbed text.
169 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
170 dnl Undisturbed text.
174 ## --------------- ##
176 ## --------------- ##
178 TMP=$TMP_BASE-widest-prefix
180 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
181 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
182 #### 2008 Free Software Foundation, Inc.
184 UPDATE_COPYRIGHT_YEAR=2010 \
185 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
186 compare /dev/null $TMP-stdout || exit 1
187 compare /dev/null $TMP-stderr || exit 1
188 compare - $TMP <<EOF || exit 1
189 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
190 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
191 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
195 ## ------------------- ##
196 ## Prefix too large. ##
197 ## ------------------- ##
199 TMP=$TMP_BASE-prefix-too-large
201 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
202 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
203 #### 2008 Free Software Foundation, Inc.
205 UPDATE_COPYRIGHT_YEAR=2010 \
206 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
207 compare /dev/null $TMP-stdout || exit 1
208 compare - $TMP-stderr <<EOF || exit 1
209 $TMP: warning: FSF copyright statement not found
211 compare - $TMP <<EOF || exit 1
212 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
213 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
214 #### 2008 Free Software Foundation, Inc.
222 TMP=$TMP_BASE-blank-lines
224 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
226 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
227 #2008 Free Software Foundation, Inc.
229 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
231 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
232 2008 Free Software Foundation, Inc.
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 - $TMP-stderr <<EOF || exit 1
238 $TMP: warning: FSF copyright statement not found
240 compare - $TMP <<EOF || exit 1
241 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
243 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
244 #2008 Free Software Foundation, Inc.
246 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
248 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
249 2008 Free Software Foundation, Inc.
257 TMP=$TMP_BASE-leading-tabs
259 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
260 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
261 Software Foundation, Inc.
263 UPDATE_COPYRIGHT_YEAR=2010 \
264 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
265 compare /dev/null $TMP-stdout || exit 1
266 compare /dev/null $TMP-stderr || exit 1
267 compare - $TMP <<EOF || exit 1
268 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
269 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
270 2009-2010 Free Software Foundation, Inc.
274 ## -------------------- ##
275 ## Unusual whitespace. ##
276 ## -------------------- ##
278 TMP=$TMP_BASE-unusual-ws
280 # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
281 # 98, 1999, 2000, 2001, 2002, 2003,
\f 2004, 2005, 2006, 2007, 2008,
282 # 2009 Free Software Foundation, Inc.
284 UPDATE_COPYRIGHT_YEAR=2010 \
285 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
286 compare /dev/null $TMP-stdout || exit 1
287 compare /dev/null $TMP-stderr || exit 1
288 compare - $TMP <<EOF || exit 1
289 # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995,
290 # 1996, 1997, 98, 1999, 2000, 2001, 2002, 2003, 2004,
291 # 2005, 2006, 2007, 2008, 2009-2010 Free Software
300 TMP=$TMP_BASE-dos-eol
301 tr @ '\015' > $TMP <<\EOF
302 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
303 Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
304 Rem 2009 Free Software Foundation, Inc.@
306 UPDATE_COPYRIGHT_YEAR=2010 \
307 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
308 compare /dev/null $TMP-stdout || exit 1
309 compare /dev/null $TMP-stderr || exit 1
310 tr @ '\015' > $TMP-exp <<\EOF
311 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,@
312 Rem 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
313 Rem 2009-2010 Free Software Foundation, Inc.@
315 compare $TMP-exp $TMP || exit 1