py-compile-env.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  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.
  8. #
  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.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Make sure 'py-compile' honours the PYTHON environment variable.
  17. . test-init.sh
  18. cp "$am_scriptdir/py-compile" . \
  19. || fatal_ "failed to fetch auxiliary script py-compile"
  20. cat > my-py <<'END'
  21. #!/bin/sh
  22. : > my-py.run
  23. END
  24. chmod a+x my-py
  25. mkdir sub1
  26. cd sub1
  27. PYTHON=: ../py-compile foo.py
  28. ls | grep . && exit 1
  29. PYTHON=false ../py-compile foo.py && exit 1
  30. ls | grep . && exit 1
  31. PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py
  32. PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py | grep 'GrEpMe AndMeToo'
  33. ls | grep . && exit 1
  34. cd ..
  35. mkdir sub2
  36. cd sub2
  37. PYTHON=../my-py ../py-compile foo.py
  38. test -f my-py.run
  39. ls | grep -v '^my-py\.run$' | grep . && exit 1
  40. cd ..
  41. mkdir sub3
  42. cd sub3
  43. PATH=..$PATH_SEPARATOR$PATH; export PATH
  44. PYTHON=my-py py-compile foo.py
  45. test -f my-py.run
  46. ls | grep -v '^my-py\.run$' | grep . && exit 1
  47. :