maint: Update HACKING
[automake.git] / t / instmany-python.sh
blob542251b972197fbc353c2ca2462e04f2ecf39bf1
1 #! /bin/sh
2 # Copyright (C) 2008-2017 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Installing many files should not exceed the command line length limit.
19 # This is the python sister test of 'instmany.sh', see there for details.
21 required='python'
22 . test-init.sh
24 limit=2500
25 subdir=long_subdir_name_with_many_characters
26 nfiles=81
27 list=$(seq_ 1 $nfiles)
29 oPATH=$PATH; export oPATH
30 nPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATH
32 mkdir x-bin
34 sed "s|@limit@|$limit|g" >x-bin/my-install <<'END'
35 #! /bin/sh
36 limit=@limit@
37 PATH=$oPATH; export PATH
38 if test -z "$orig_INSTALL"; then
39 echo "$0: \$orig_INSTALL variable not set" >&2
40 exit 1
42 len=`expr "$orig_INSTALL $*" : ".*" 2>/dev/null || echo $limit`
43 if test $len -ge $limit; then
44 echo "$0: safe command line limit of $limit characters exceeded" >&2
45 exit 1
47 exec $orig_INSTALL "$@"
48 exit 1
49 END
51 # Creative quoting in the next line to please maintainer-check.
52 sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'
53 #! /bin/sh
54 limit=@limit@
55 PATH=$oPATH; export PATH
56 RM='rm -f'
57 len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
58 if test $len -ge $limit; then
59 echo "$0: safe command line limit of $limit characters exceeded" >&2
60 exit 1
62 exec $RM "$@"
63 exit 1
64 END
66 # Creative quoting in the next line to please maintainer-check.
67 chmod +x x-bin/'rm' x-bin/my-install
69 cat >setenv.in <<'END'
70 orig_INSTALL='@INSTALL@'
71 # In case we've falled back on the install-sh script (seen e.g.,
72 # on AIX 7.1), we need to make sure we use its absolute path,
73 # as we don't know from which directory we'll be run.
74 case "$orig_INSTALL" in
75 /*) ;;
76 */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;
77 esac
78 export orig_INSTALL
79 END
81 cat >>configure.ac <<END
82 AM_PATH_PYTHON
83 AC_CONFIG_FILES([setenv.sh:setenv.in])
84 AC_CONFIG_FILES([$subdir/Makefile])
85 AC_OUTPUT
86 END
88 cat >Makefile.am <<END
89 SUBDIRS = $subdir
90 END
92 mkdir $subdir
93 cd $subdir
95 cat >Makefile.am <<'END'
96 python_PYTHON =
97 nobase_python_PYTHON =
98 END
100 for n in $list; do
101 unindent >>Makefile.am <<END
102 python_PYTHON += python$n.py
103 nobase_python_PYTHON += npython$n.py
105 echo >python$n.py
106 echo >npython$n.py
107 done
109 cd ..
110 $ACLOCAL
111 $AUTOCONF
112 $AUTOMAKE --add-missing
114 instdir=$(pwd)/inst
115 mkdir build
116 cd build
117 ../configure --prefix="$instdir"
118 . ./setenv.sh
119 test -n "$orig_INSTALL"
120 $MAKE
121 # Try whether native install (or install-sh) works.
122 $MAKE install
123 test -n "$(find "$instdir" -name python1.py)"
124 # Multiple uninstall should work, too.
125 $MAKE uninstall
126 $MAKE uninstall
127 test $(find "$instdir" -type f -print | wc -l) -eq 0
129 # Try whether we don't exceed the low limit.
130 PATH=$nPATH; export PATH
131 run_make INSTALL=my-install install
132 test -n "$(find "$instdir" -name python1.py)"
133 run_make INSTALL=my-install uninstall
134 test $(find "$instdir" -type f -print | wc -l) -eq 0
135 PATH=$oPATH; export PATH
137 cd $subdir
138 srcdir=../../$subdir
140 # Ensure 'make install' fails when 'install' fails.
142 for file in python3.py python$nfiles.py
144 chmod a-r $srcdir/$file
145 test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
146 $MAKE install && exit 1
147 chmod u+r $srcdir/$file
148 done
150 for file in npython3.py npython$nfiles.py
152 chmod a-r $srcdir/$file
153 $MAKE install && exit 1
154 chmod u+r $srcdir/$file
155 done