summaryrefslogtreecommitdiff
path: root/t/clean-many.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/clean-many.sh')
-rw-r--r--t/clean-many.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/t/clean-many.sh b/t/clean-many.sh
new file mode 100644
index 000000000..f64c2d2df
--- /dev/null
+++ b/t/clean-many.sh
@@ -0,0 +1,63 @@
+#! /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 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
+
+: