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 TMP_BASE=update-copyright.test
21 ## ----------------------------- ##
22 ## Examples from documentation. ##
23 ## ----------------------------- ##
27 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
31 # Copyright (C) 1990-2005, 2007-2009 Free Software
36 * Copyright © 90,2005,2007-2009
37 * Free Software Foundation, Inc.
41 /* Copyright (C) 1990-2005, 2007-2009 Free Software
44 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
48 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
50 # Copyright (C) 1990-2005, 2007-2009 Free Software
54 UPDATE_COPYRIGHT_YEAR=2009 \
55 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
56 diff -u /dev/null $TMP-stdout || exit 1
57 diff -u - $TMP-stderr <<EOF || exit 1
58 $TMP.4: warning: FSF copyright statement not found
59 $TMP.5: warning: FSF copyright statement not found
61 diff -u - $TMP.1 <<EOF || exit 1
62 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
65 diff -u - $TMP.2 <<EOF || exit 1
66 # Copyright (C) 1990-2005, 2007-2009 Free Software
69 diff -u - $TMP.3 <<EOF || exit 1
71 * Copyright © 90,2005,2007-2009
72 * Free Software Foundation, Inc.
75 diff -u - $TMP.4 <<EOF || exit 1
76 /* Copyright (C) 1990-2005, 2007-2009 Free Software
79 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
82 diff -u - $TMP.5 <<EOF || exit 1
83 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
85 # Copyright (C) 1990-2005, 2007-2009 Free Software
89 UPDATE_COPYRIGHT_YEAR=2010 \
90 update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
91 diff -u /dev/null $TMP-stdout || exit 1
92 diff -u - $TMP-stderr <<EOF || exit 1
93 $TMP.4: warning: FSF copyright statement not found
94 $TMP.5: warning: FSF copyright statement not found
96 diff -u - $TMP.1 <<EOF || exit 1
97 Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation,
100 diff -u - $TMP.2 <<EOF || exit 1
101 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
103 diff -u - $TMP.3 <<EOF || exit 1
105 * Copyright © 90, 2005, 2007-2010 Free Software Foundation, Inc.
108 diff -u - $TMP.4 <<EOF || exit 1
109 /* Copyright (C) 1990-2005, 2007-2009 Free Software
110 * Foundation, Inc. */
112 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
115 diff -u - $TMP.5 <<EOF || exit 1
116 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
118 # Copyright (C) 1990-2005, 2007-2009 Free Software
128 TMP=$TMP_BASE-current-year
129 YEAR=`/usr/bin/perl -e 'print [localtime]->[5] + 1900'`;
131 '\" Copyright (C) 2006
132 '\" Free Software Foundation,
135 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
136 diff -u /dev/null $TMP-stdout || exit 1
137 diff -u /dev/null $TMP-stderr || exit 1
138 diff -u - $TMP <<EOF || exit 1
139 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
143 ## ------------------ ##
144 ## Surrounding text. ##
145 ## ------------------ ##
147 TMP=$TMP_BASE-surrounding-text
150 dnl Undisturbed text.
152 dnl Free Software Foundation, Inc.
153 dnl Undisturbed text.
155 UPDATE_COPYRIGHT_YEAR=2010 \
156 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
157 diff -u /dev/null $TMP-stdout || exit 1
158 diff -u /dev/null $TMP-stderr || exit 1
159 diff -u - $TMP <<EOF || exit 1
161 dnl Undisturbed text.
162 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
163 dnl Undisturbed text.
167 ## --------------- ##
169 ## --------------- ##
171 TMP=$TMP_BASE-widest-prefix
173 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
174 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
175 #### 2008 Free Software Foundation, Inc.
177 UPDATE_COPYRIGHT_YEAR=2010 \
178 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
179 diff -u /dev/null $TMP-stdout || exit 1
180 diff -u /dev/null $TMP-stderr || exit 1
181 diff -u - $TMP <<EOF || exit 1
182 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
183 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
184 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
188 ## ------------------- ##
189 ## Prefix too large. ##
190 ## ------------------- ##
192 TMP=$TMP_BASE-prefix-too-large
194 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
195 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
196 #### 2008 Free Software Foundation, Inc.
198 UPDATE_COPYRIGHT_YEAR=2010 \
199 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
200 diff -u /dev/null $TMP-stdout || exit 1
201 diff -u - $TMP-stderr <<EOF || exit 1
202 $TMP: warning: FSF copyright statement not found
204 diff -u - $TMP <<EOF || exit 1
205 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
206 #### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
207 #### 2008 Free Software Foundation, Inc.
215 TMP=$TMP_BASE-blank-lines
217 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
219 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
220 #2008 Free Software Foundation, Inc.
222 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
224 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
225 2008 Free Software Foundation, Inc.
227 UPDATE_COPYRIGHT_YEAR=2010 \
228 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
229 diff -u /dev/null $TMP-stdout || exit 1
230 diff -u - $TMP-stderr <<EOF || exit 1
231 $TMP: warning: FSF copyright statement not found
233 diff -u - $TMP <<EOF || exit 1
234 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
236 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
237 #2008 Free Software Foundation, Inc.
239 Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
241 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
242 2008 Free Software Foundation, Inc.
250 TMP=$TMP_BASE-leading-tabs
252 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
253 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
254 Software Foundation, Inc.
256 UPDATE_COPYRIGHT_YEAR=2010 \
257 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
258 diff -u /dev/null $TMP-stdout || exit 1
259 diff -u /dev/null $TMP-stderr || exit 1
260 diff -u - $TMP <<EOF || exit 1
261 Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
262 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
263 2009-2010 Free Software Foundation, Inc.
267 ## -------------------- ##
268 ## Unusual whitespace. ##
269 ## -------------------- ##
271 TMP=$TMP_BASE-unusual-ws
273 # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
274 # 98, 1999, 2000, 2001, 2002, 2003,
\f 2004, 2005, 2006, 2007, 2008,
275 # 2009 Free Software Foundation, Inc.
277 UPDATE_COPYRIGHT_YEAR=2010 \
278 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
279 diff -u /dev/null $TMP-stdout || exit 1
280 diff -u /dev/null $TMP-stderr || exit 1
281 diff -u - $TMP <<EOF || exit 1
282 # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995,
283 # 1996, 1997, 98, 1999, 2000, 2001, 2002, 2003, 2004,
284 # 2005, 2006, 2007, 2008, 2009-2010 Free Software
293 TMP=$TMP_BASE-dos-eol
294 tr @ '\015' > $TMP <<\EOF
295 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@
296 Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
297 Rem 2009 Free Software Foundation, Inc.@
299 UPDATE_COPYRIGHT_YEAR=2010 \
300 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
301 diff -u /dev/null $TMP-stdout || exit 1
302 diff -u /dev/null $TMP-stderr || exit 1
303 tr @ '\015' > $TMP-exp <<\EOF
304 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,@
305 Rem 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
306 Rem 2009-2010 Free Software Foundation, Inc.@
308 diff -u $TMP-exp $TMP || exit 1