summaryrefslogtreecommitdiff
path: root/t/python-missing.sh
blob: 946358372369d901810635bbdbf19d0c5356d3f5 (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) 2003-2018 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 <https://www.gnu.org/licenses/>.

# Test detection of missing Python.
# See also related test t/python-am-path-missing-2.sh (which requires
# an actual python program).

am_create_testdir=empty
# An actual python is *not* required in this test.
. test-init.sh

unset PYTHON

cat > configure.ac <<END
AC_INIT([$me], [1.0])
m4_include([mypy.m4])
AC_OUTPUT
END

echo AM_PATH_PYTHON > mypy.m4

$ACLOCAL
$AUTOCONF

# Simulate no Python.
./configure PYTHON=: 2>stderr && { cat stderr >&2; exit 1; }
cat stderr >&2
grep 'no suitable Python interpreter found' stderr

# Again, but from the environment this time.
env PYTHON=: ./configure 2>stderr && { cat stderr >&2; exit 1; }
cat stderr >&2
grep 'no suitable Python interpreter found' stderr

# Now try using a custom ACTION-IF-NOT-FOUND.

echo 'AM_PATH_PYTHON(,, [echo "$PYTHON" > py])' > mypy.m4
$AUTOCONF --force
./configure PYTHON=:
test x"$(cat py)" = x:

# Now try requiring a version.

rm -rf autom4te*.cache # Will have to re-run aclocal.

# Hopefully the Python team will never release such a version :-)
echo 'AM_PATH_PYTHON([9999.9], [])' > mypy.m4
# The "--force" options (here and below) are truly needed to avoid
# potential timestamp races.  See automake bug#12210.
$ACLOCAL --force
$AUTOCONF --force
./configure >stdout 2>stderr && {
  cat stdout
  cat stderr >&2
  exit 1
}
cat stdout
cat stderr >&2
$EGREP 'checking for a Python interpreter with version >= 9999\.9\.\.\. no(ne)? *$' stdout
grep 'no suitable Python interpreter found' stderr

# Now try requiring a version and using a custom ACTION-IF-NOT-FOUND.

echo 'AM_PATH_PYTHON([9999.9], [], [echo "$PYTHON" > py])' > mypy.m4
$AUTOCONF --force
./configure
test x"$(cat py)" = x:

: