Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / py-compile-basic.test
1 #! /bin/sh
2 # Copyright (C) 2011 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
17 # Test more basic functionalities of the `py-compile' script,
18 # with "believable" python sources.  See also related test
19 # `py-compile-basic2.test'.
20
21 required=python
22 . ./defs || Exit 1
23
24 set -e
25
26 cp "$testsrcdir/../lib/py-compile" .
27
28 cat > foo.py <<'END'
29 # Try out some non-trivial syntax in here.
30
31 '''Module docstring'''
32
33 def foo (*args, **kwargs):
34   """Function docstring
35   with embedded newline"""
36   return 1
37
38 class Foo:
39   r"""Class docstring"""
40   def __init__(self):
41     r'''Method docstring
42         with
43         embedded
44         newlines'''
45     pass
46
47 bar = baz = (1, (2,), [3, 4]); zardoz = 0;
48 END
49
50 cat > bar.py <<'END'
51 # Import of non-existent modules, or assertion of false conditions,
52 # shouldn't cause problems, as it should be enough for the code to
53 # be syntactically correct.
54 import Automake.No.Such.Module
55 assert False
56 END
57
58 ./py-compile foo.py bar.py
59 test -f foo.pyc
60 test -f foo.pyo
61 test -f bar.pyc
62 test -f bar.pyo
63
64 :