summaryrefslogtreecommitdiff
path: root/t/clean-many.sh
blob: 27208acc2f1b987d85d40193926423aa339b7ad6 (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
#! /bin/sh
# Copyright (C) 2012-2015 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 a huge number
# of files to be removed.  Checks similar in spirit are done by sister
# test 'clean-many2.sh', which fakes an artificially low command line
# length limit for 'rm'.

. test-init.sh

cat >> configure.ac << 'END'
AC_SUBST([safe_include], [include])
AC_OUTPUT
END

cat > Makefile.am <<'END'
# Don't use 'include' here: we want this processed at make runtime,
# not at automake runtime.  Otherwise Automake runs too slow.
@safe_include@ files.mk
MOSTLYCLEANFILES = $(files)
CLEANFILES = $(files)
DISTCLEANFILES = $(files)
MAINTANERCLEANFILES = $(files)
END

$ACLOCAL
$AUTOCONF
$AUTOMAKE
./configure

# Yes, we want to clean ~ 130 thousands files.  So what?
i=2
echo foo bar > t
while test $i -le 17; do
  i=$(($i + 1))
  cat t t > t2
  mv -f t2 t
done
(echo 'files = \' && sed '$!s/$/ \\/' t) > files.mk
rm -f t

# 2^17 + 1 = 65537.
test $(wc -l <files.mk) -eq 65537 || fatal_ "populating 'files.mk'"

touch foo bar
$MAKE maintainer-clean
test ! -e foo
test ! -e bar

: