summaryrefslogtreecommitdiff
path: root/t/py-compile-env.sh
blob: 7c39372d06887e2f9ed9f827608709c825bf2ee2 (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
#! /bin/sh
# Copyright (C) 2011-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/>.

# Make sure 'py-compile' honours the PYTHON environment variable.

. test-init.sh

cp "$am_scriptdir/py-compile" . \
  || fatal_ "failed to fetch auxiliary script py-compile"

cat > my-py <<'END'
#!/bin/sh
: > my-py.run
END
chmod a+x my-py

mkdir sub1
cd sub1

PYTHON=: ../py-compile foo.py
ls | grep . && exit 1

PYTHON=false ../py-compile foo.py && exit 1
ls | grep . && exit 1

PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py
PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py | grep 'GrEpMe AndMeToo'
ls | grep . && exit 1

cd ..
mkdir sub2
cd sub2

PYTHON=../my-py ../py-compile foo.py
test -f my-py.run
ls | grep -v '^my-py\.run$' | grep . && exit 1

cd ..
mkdir sub3
cd sub3
PATH=..$PATH_SEPARATOR$PATH; export PATH
PYTHON=my-py py-compile foo.py
test -f my-py.run
ls | grep -v '^my-py\.run$' | grep . && exit 1

: