[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: updating copyright years
From: |
Joel E. Denny |
Subject: |
Re: updating copyright years |
Date: |
Mon, 3 Aug 2009 20:19:50 -0400 (EDT) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
On Sat, 1 Aug 2009, Joel E. Denny wrote:
> > No objection on principle, from me. The 'update-copyright' module
> > works fine for me in most cases. But it has no testsuite, therefore it
> > may surprise us.
>
> My test suite has mostly been coreutils and bison (plus a few handwritten
> tests for quicker testing). I'll be glad to put something more formal
> together. I'm a little busy at the moment, and I have to study how gnulib
> does testing, but I'll try to post soon.
The following patch adds a test suite. The command I've been using to run
it is:
./gnulib-tool --test --with-tests update-copyright
However, "./gnulib-tool --help" says --with-tests is meant for --import.
Is there a better command to run the test suite?
> Also, I posted some major changes to update-copyright here:
>
> http://lists.gnu.org/archive/html/bug-gnulib/2009-07/msg00135.html
I found a bug in that code, which the following patch fixes.
>From 1e91305468e96d8eea16a151fc7b63745d66b47b Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Mon, 3 Aug 2009 20:05:50 -0400
Subject: [PATCH] update-copyright: fix bug for 2-digit last year and add tests
* build-aux/update-copyright: Fix bug.
Use UPDATE_COPYRIGHT_YEAR from environment as current year if
specified.
* modules/update-copyright-tests: New
* tests/test-update-copyright.sh: New.
---
ChangeLog | 9 ++
build-aux/update-copyright | 20 ++-
modules/update-copyright-tests | 12 ++
tests/test-update-copyright.sh | 309 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 342 insertions(+), 8 deletions(-)
create mode 100644 modules/update-copyright-tests
create mode 100755 tests/test-update-copyright.sh
diff --git a/ChangeLog b/ChangeLog
index bb70705..56d85e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-08-03 Joel E. Denny <address@hidden>
+
+ update-copyright: fix bug for 2-digit last year and add tests
+ * build-aux/update-copyright: Fix bug.
+ Use UPDATE_COPYRIGHT_YEAR from environment as current year if
+ specified.
+ * modules/update-copyright-tests: New
+ * tests/test-update-copyright.sh: New.
+
2009-07-31 Joel E. Denny <address@hidden>
update-copyright: handle leading tabs in line prefix
diff --git a/build-aux/update-copyright b/build-aux/update-copyright
index 5b2a465..39071ab 100755
--- a/build-aux/update-copyright
+++ b/build-aux/update-copyright
@@ -1,7 +1,7 @@
#!/usr/bin/perl -0777 -pi
# Update an FSF copyright year list to include the current year.
-my $VERSION = '2009-07-31.12:44'; # UTC
+my $VERSION = '2009-08-03.23:03'; # UTC
# Copyright (C) 2009 Free Software Foundation
#
@@ -49,7 +49,7 @@ my $VERSION = '2009-07-31.12:44'; # UTC
# Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
# Inc.
#
-# # Copyright (C) 1990-2005, 2007-2009 Free Software
+# # Copyright (c) 1990-2005, 2007-2009 Free Software
# # Foundation, Inc.
#
# /*
@@ -100,8 +100,11 @@ my $VERSION = '2009-07-31.12:44'; # UTC
use strict;
use warnings;
-my ($sec, $min, $hour, $mday, $month, $year) = localtime (time());
-my $this_year = $year + 1900;
+my $this_year = $ENV{UPDATE_COPYRIGHT_YEAR};
+if (!$this_year || $this_year !~ m/^\d\d(\d\d)?$/) {
+ my ($sec, $min, $hour, $mday, $month, $year) = localtime (time());
+ $this_year = $year + 1900;
+}
my $copyright = 'Copyright \([cC]\)';
my $holder = 'Free Software Foundation, Inc.';
my $prefix_max = 5;
@@ -131,9 +134,10 @@ if (defined($old) && /$old/)
{
my $new = $1;
my $sep = $2 ? $2 : "";
- my $last_c_year = $3;
+ my $last_year = $3;
# Handle two-digit year numbers like "98" and "99".
+ my $last_c_year = $last_year;
$last_c_year <= 99
and $last_c_year += 1900;
@@ -142,15 +146,15 @@ if (defined($old) && /$old/)
# Update the year.
if ($sep eq '-' && $last_c_year + 1 == $this_year)
{
- $new =~ s/$last_c_year/$this_year/;
+ $new =~ s/$last_year/$this_year/;
}
elsif ($sep ne '-' && $last_c_year + 1 == $this_year)
{
- $new =~ s/$last_c_year/$last_c_year-$this_year/;
+ $new =~ s/$last_year/$last_c_year-$this_year/;
}
else
{
- $new =~ s/$last_c_year/$last_c_year, $this_year/;
+ $new =~ s/$last_year/$last_c_year, $this_year/;
}
# Normalize all whitespace including newline-prefix sequences.
diff --git a/modules/update-copyright-tests b/modules/update-copyright-tests
new file mode 100644
index 0000000..5dc8ee1
--- /dev/null
+++ b/modules/update-copyright-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-update-copyright.sh
+
+Depends-on:
+
+configure.ac:
+abs_aux_dir=`cd "$ac_aux_dir"; pwd`
+AC_SUBST([abs_aux_dir])
+
+Makefile.am:
+TESTS += test-update-copyright.sh
+TESTS_ENVIRONMENT += PATH='$(abs_aux_dir)'$(PATH_SEPARATOR)"$$PATH"
diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh
new file mode 100755
index 0000000..511d5ee
--- /dev/null
+++ b/tests/test-update-copyright.sh
@@ -0,0 +1,309 @@
+#!/bin/sh
+# Test suite for update-copyright.
+# Copyright (C) 2009 Free Software Foundation, Inc.
+# This file is part of the GNUlib Library.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+TMP_BASE=update-copyright.test
+
+## ----------------------------- ##
+## Examples from documentation. ##
+## ----------------------------- ##
+
+TMP=$TMP_BASE-ex
+cat > $TMP.1 <<EOF
+Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
+Inc.
+EOF
+cat > $TMP.2 <<EOF
+# Copyright (c) 1990-2005, 2007-2009 Free Software
+# Foundation, Inc.
+EOF
+cat > $TMP.3 <<EOF
+/*
+ * Copyright (C) 90,2005,2007-2009 Free Software
+ * Foundation, Inc.
+ */
+EOF
+cat > $TMP.4 <<EOF
+/* Copyright (C) 1990-2005, 2007-2009 Free Software
+ * Foundation, Inc. */
+
+Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
+Inc.
+EOF
+cat > $TMP.5 <<EOF
+Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
+
+# Copyright (C) 1990-2005, 2007-2009 Free Software
+# Foundation, Inc.
+EOF
+
+UPDATE_COPYRIGHT_YEAR=2009 \
+ update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u - $TMP-stderr <<EOF || exit 1
+$TMP.4: warning: FSF copyright statement not found
+$TMP.5: warning: FSF copyright statement not found
+EOF
+diff -u - $TMP.1 <<EOF || exit 1
+Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
+Inc.
+EOF
+diff -u - $TMP.2 <<EOF || exit 1
+# Copyright (c) 1990-2005, 2007-2009 Free Software
+# Foundation, Inc.
+EOF
+diff -u - $TMP.3 <<EOF || exit 1
+/*
+ * Copyright (C) 90,2005,2007-2009 Free Software
+ * Foundation, Inc.
+ */
+EOF
+diff -u - $TMP.4 <<EOF || exit 1
+/* Copyright (C) 1990-2005, 2007-2009 Free Software
+ * Foundation, Inc. */
+
+Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
+Inc.
+EOF
+diff -u - $TMP.5 <<EOF || exit 1
+Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
+
+# Copyright (C) 1990-2005, 2007-2009 Free Software
+# Foundation, Inc.
+EOF
+
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u - $TMP-stderr <<EOF || exit 1
+$TMP.4: warning: FSF copyright statement not found
+$TMP.5: warning: FSF copyright statement not found
+EOF
+diff -u - $TMP.1 <<EOF || exit 1
+Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
+EOF
+diff -u - $TMP.2 <<EOF || exit 1
+# Copyright (c) 1990-2005, 2007-2010 Free Software Foundation, Inc.
+EOF
+diff -u - $TMP.3 <<EOF || exit 1
+/*
+ * Copyright (C) 90, 2005, 2007-2010 Free Software Foundation, Inc.
+ */
+EOF
+diff -u - $TMP.4 <<EOF || exit 1
+/* Copyright (C) 1990-2005, 2007-2009 Free Software
+ * Foundation, Inc. */
+
+Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
+Inc.
+EOF
+diff -u - $TMP.5 <<EOF || exit 1
+Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
+
+# Copyright (C) 1990-2005, 2007-2009 Free Software
+# Foundation, Inc.
+EOF
+
+rm $TMP*
+
+## -------------- ##
+## Current year. ##
+## -------------- ##
+
+TMP=$TMP_BASE-current-year
+YEAR=`/usr/bin/perl -e 'print [localtime]->[5] + 1900'`;
+cat > $TMP <<EOF
+'\" Copyright (C) 2006
+'\" Free Software Foundation,
+'\" Inc.
+EOF
+update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u /dev/null $TMP-stderr || exit 1
+diff -u - $TMP <<EOF || exit 1
+'\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
+EOF
+rm $TMP*
+
+## ------------------ ##
+## Surrounding text. ##
+## ------------------ ##
+
+TMP=$TMP_BASE-surrounding-text
+cat > $TMP <<EOF
+ Undisturbed text.
+dnl Undisturbed text.
+dnl Copyright (C) 89
+dnl Free Software Foundation, Inc.
+dnl Undisturbed text.
+EOF
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u /dev/null $TMP-stderr || exit 1
+diff -u - $TMP <<EOF || exit 1
+ Undisturbed text.
+dnl Undisturbed text.
+dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
+dnl Undisturbed text.
+EOF
+rm $TMP*
+
+## --------------- ##
+## Widest prefix. ##
+## --------------- ##
+
+TMP=$TMP_BASE-widest-prefix
+cat > $TMP <<EOF
+#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
+#### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+#### 2008 Free Software Foundation, Inc.
+EOF
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u /dev/null $TMP-stderr || exit 1
+diff -u - $TMP <<EOF || exit 1
+#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
+#### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+#### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
+EOF
+rm $TMP*
+
+## ------------------- ##
+## Prefix too large. ##
+## ------------------- ##
+
+TMP=$TMP_BASE-prefix-too-large
+cat > $TMP <<EOF
+#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
+#### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+#### 2008 Free Software Foundation, Inc.
+EOF
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u - $TMP-stderr <<EOF || exit 1
+$TMP: warning: FSF copyright statement not found
+EOF
+diff -u - $TMP <<EOF || exit 1
+#### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
+#### 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+#### 2008 Free Software Foundation, Inc.
+EOF
+rm $TMP*
+
+## ------------- ##
+## Blank lines. ##
+## ------------- ##
+
+TMP=$TMP_BASE-blank-lines
+cat > $TMP <<EOF
+#Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
+#
+#1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+#2008 Free Software Foundation, Inc.
+
+Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
+
+1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+2008 Free Software Foundation, Inc.
+EOF
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u - $TMP-stderr <<EOF || exit 1
+$TMP: warning: FSF copyright statement not found
+EOF
+diff -u - $TMP <<EOF || exit 1
+#Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
+#
+#1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+#2008 Free Software Foundation, Inc.
+
+Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
+
+1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+2008 Free Software Foundation, Inc.
+EOF
+rm $TMP*
+
+## -------------- ##
+## Leading tabs. ##
+## -------------- ##
+
+TMP=$TMP_BASE-leading-tabs
+cat > $TMP <<EOF
+ Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
+ Software Foundation, Inc.
+EOF
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u /dev/null $TMP-stderr || exit 1
+diff -u - $TMP <<EOF || exit 1
+ Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+ 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+ 2009-2010 Free Software Foundation, Inc.
+EOF
+rm $TMP*
+
+## -------------------- ##
+## Unusual whitespace. ##
+## -------------------- ##
+
+TMP=$TMP_BASE-unusual-ws
+cat > $TMP <<EOF
+ # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996,
1997,
+ # 98, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008,
+ # 2009 Free Software Foundation, Inc.
+EOF
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u /dev/null $TMP-stderr || exit 1
+diff -u - $TMP <<EOF || exit 1
+ # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995,
+ # 1996, 1997, 98, 1999, 2000, 2001, 2002, 2003, 2004,
+ # 2005, 2006, 2007, 2008, 2009-2010 Free Software
+ # Foundation, Inc.
+EOF
+rm $TMP*
+
+## --------- ##
+## DOS EOL. ##
+## --------- ##
+
+TMP=$TMP_BASE-dos-eol
+cat > $TMP <<EOF
+Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+Rem 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+Rem 2009 Free Software Foundation, Inc.
+EOF
+UPDATE_COPYRIGHT_YEAR=2010 \
+ update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
+diff -u /dev/null $TMP-stdout || exit 1
+diff -u /dev/null $TMP-stderr || exit 1
+diff -u - $TMP <<EOF || exit 1
+Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,
+Rem 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+Rem 2009-2010 Free Software Foundation, Inc.
+EOF
+rm $TMP*
+
+exit 0
--
1.5.4.3
- Re: [PATCH] lib/sha1.h: wrap declarations in extern "C" scope when included from C++, Bruno Haible, 2009/08/01
- Re: [PATCH] lib/sha1.h: wrap declarations in extern "C" scope when included from C++, Jim Meyering, 2009/08/01
- Re: updating copyright years, Bruno Haible, 2009/08/01
- Re: updating copyright years, Joel E. Denny, 2009/08/01
- Re: updating copyright years, Simon Josefsson, 2009/08/02
- Re: updating copyright years,
Joel E. Denny <=
- Re: updating copyright years, Joel E. Denny, 2009/08/03
- Re: updating copyright years, Joel E. Denny, 2009/08/04
- Re: updating copyright years, Jim Meyering, 2009/08/04
- Re: updating copyright years, Joel E. Denny, 2009/08/04
- Re: ChangeLog patches, Bruno Haible, 2009/08/04
- Re: ChangeLog patches, Joel E. Denny, 2009/08/04
- Re: updating copyright years, Matthew Woehlke, 2009/08/04
- Re: updating copyright years, Joel E. Denny, 2009/08/04
- Re: updating copyright years, Karl Berry, 2009/08/04
- Re: updating copyright years, Joel E. Denny, 2009/08/04