2
0

py-compile-basic.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. # Test more basic functionalities of the 'py-compile' script,
  17. # with "believable" python sources. See also related test
  18. # 'py-compile-basic2.sh'.
  19. required=python
  20. . test-init.sh
  21. cp "$am_scriptdir/py-compile" . \
  22. || fatal_ "failed to fetch auxiliary script py-compile"
  23. cat > foo.py <<'END'
  24. # Try out some non-trivial syntax in here.
  25. '''Module docstring'''
  26. def foo (*args, **kwargs):
  27. """Function docstring
  28. with embedded newline"""
  29. return 1
  30. class Foo:
  31. r"""Class docstring"""
  32. def __init__(self):
  33. r'''Method docstring
  34. with
  35. embedded
  36. newlines'''
  37. pass
  38. bar = baz = (1, (2,), [3, 4]); zardoz = 0;
  39. END
  40. mkdir sub
  41. cat > sub/bar.py <<'END'
  42. # Import of non-existent modules, or assertion of false conditions,
  43. # shouldn't cause problems, as it should be enough for the code to
  44. # be syntactically correct.
  45. import Automake.No.Such.Module
  46. assert False
  47. END
  48. # An empty file in a more deeply-nested directory should be ok as well.
  49. mkdir -p 1/_/2/_/3/_
  50. : > 1/_/2/_/3/_/0.py
  51. ./py-compile foo.py sub/bar.py 1/_/2/_/3/_/0.py
  52. py_installed foo.pyc
  53. py_installed foo.pyo
  54. py_installed sub/bar.pyc
  55. py_installed sub/bar.pyo
  56. py_installed 1/_/2/_/3/_/0.pyc
  57. py_installed 1/_/2/_/3/_/0.pyo
  58. :