summaryrefslogtreecommitdiff
path: root/t/clean-many2.sh
blob: 733d71fdf11b09263092737a8f0d52a1859841e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /bin/sh
# Copyright (C) 2012-2014 Free Software Foundation, Inc.
#
# 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 2, 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/>.

# Check that our cleaning rules do not hit errors due to an exceeded
# command line length when there are many files to clean.  Here, we
# fake a very low command line length limit for 'rm' (max 50 arguments).
# The sister test 'clean-many.sh' try to hit the real command line length
# limit of the system, by declaring a huge number of files to be cleaned.

. test-init.sh

echo AC_OUTPUT >> configure.ac

oPATH=$PATH; export oPATH
mkdir bin
# Redundant quoting of 'rm' (here and below) to please maintainer-check.
cat > bin/'rm' <<'END'
#!/bin/sh
PATH=$oPATH; export PATH
if test $# -eq 0; then
  echo "rm: missing argument" >&2
  exit 1
elif test $# -gt 50; then
  echo "rm: argument list too long ($# arguments)" >&2
  exit 1
fi
exec 'rm' "$@"
END
chmod a+x bin/rm
PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH

cat > Makefile.am <<'END'
MOSTLYCLEANFILES = $(files)
CLEANFILES = $(files)
DISTCLEANFILES = $(files)
MAINTANERCLEANFILES = $(files)
include files.am
END

echo foo bar > t
i=1
while test $i -le 10; do
  cat t t > t2 && mv -f t2 t || exit 99
  i=$(($i + 1))
done

# Sanity check.
rm -f $(cat t) && fatal_ "setting up 'rm' wrapper"

(echo 'files = \' && sed '$!s/$/ \\/' t) >files.am
rm -f t

$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
./configure
cp config.status config-status.sav \

for target in mostlyclean clean distclean maintainer-clean; do
  echo dummy > foo
  echo dummy > bar
  $MAKE $target
  test ! -e foo
  test ! -e foo
  cp config-status.sav config.status && ./config.status Makefile \
    || fatal_ "resetting Makefile after cleanup"
done

: