#!/bin/sh # Test suite for update-copyright. # Copyright (C) 2009-2024 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 . diffout=`diff -u /dev/null /dev/null 2>&1` if test x"$diffout" = x"" && test $? -eq 0; then compare() { diff -u "$@"; } else compare() { cmp "$@"; } fi # Ensure the update-copyright program gets found. PATH=$abs_aux_dir:$PATH export PATH TMP_BASE=update-copyright.test trap 'rm -f $TMP_BASE*' EXIT HUP INT QUIT TERM ## --------------------------------- ## ## Skip if user does not have perl. ## ## --------------------------------- ## TMP=$TMP_BASE s=$TMP-script cat <<\EOF > $s #!/bin/sh #! -*-perl-*- # This is a prologue that allows to run a perl script as an executable # on systems that are compliant to a POSIX version before POSIX:2017. # On such systems, the usual invocation of an executable through execlp() # or execvp() fails with ENOEXEC if it is a script that does not start # with a #! line. The script interpreter mentioned in the #! line has # to be /bin/sh, because on GuixSD systems that is the only program that # has a fixed file name. The second line is essential for perl and is # also useful for editing this file in Emacs. The next two lines below # are valid code in both sh and perl. When executed by sh, they re-execute # the script through the perl program found in $PATH. The '-x' option # is essential as well; without it, perl would re-execute the script # through /bin/sh. When executed by perl, the next two lines are a no-op. eval 'exec perl -wSx -pi "$0" "$@"' if 0; s/a/b/ EOF chmod a+x $s echo a > $TMP-in ./$s $TMP-in 2>/dev/null && test b = "`cat $TMP-in 2>/dev/null`" || { printf '%s\n' "$0: skipping this test;" \ 'your system has insufficient support for Perl' 1>&2 exit 77 } # Skip this test if Perl is too old. FIXME: 5.8.0 is just a guess. # We have a report that 5.6.1 is inadequate and that 5.8.0 works. perl -e 'require 5.8.0' || { echo "$0: skipping this test; Perl version is too old" 1>&2 exit 77 } # Do not let a different envvar setting perturb results. UPDATE_COPYRIGHT_MAX_LINE_LENGTH=72 export UPDATE_COPYRIGHT_MAX_LINE_LENGTH # This assignment to 'ight' is so that data can contain strings # like "Copy$ight 2024 Free Software Foundation, Inc." without being # mistakenly updated by "cd .. && make update-copyright". ight=right ## ----------------------------- ## ## Examples from documentation. ## ## ----------------------------- ## TMP=$TMP_BASE-ex cat > $TMP-1 < $TMP-2 < $TMP-3 < $TMP-4 < $TMP-5 < $TMP-6 < $TMP-7 < $TMP-8 < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare - $TMP-stderr < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare - $TMP-stderr < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare - $TMP-stderr < $TMP.1 < $TMP.2 < $TMP.3 < $TMP.4 < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP.1 < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare - $TMP-stderr < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare - $TMP-stderr < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 tr @ '\015' > $TMP-exp < $TMP < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP < $TMP.star < $TMP.space < $TMP.single-line < $TMP.single-line-wrapped < $TMP.extra-text-star < $TMP.extra-text-space < $TMP.two-digit-final-is-substr-of-first < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP.star <