added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / M4 / M4.py
blob1f5c67931c60d700fcaef48dbc09d5f1837fd317
1 #!/usr/bin/env python
3 # __COPYRIGHT__
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27 """
28 Test that $M4 and $M4FLAGS work as expected.
29 """
31 import os
33 import TestSCons
35 _python_ = TestSCons._python_
37 test = TestSCons.TestSCons()
39 test.write('mym4.py', """
40 import sys
41 contents = sys.stdin.read()
42 sys.stdout.write(contents.replace('M4', 'mym4.py'))
43 sys.exit(0)
44 """)
46 test.write('SConstruct', """
47 DefaultEnvironment(tools=[])
48 env = Environment(tools=['m4'],
49 M4 = r'%(_python_)s mym4.py')
50 env.M4(target = 'aaa.x', source = 'aaa.x.m4')
51 """ % locals())
53 test.write('aaa.x.m4', """\
54 line 1
56 line 3
57 """)
59 test.run()
61 test.must_match(test.workpath('aaa.x'), os.linesep.join(["line 1", "mym4.py", "line 3", ""]))
63 m4 = test.where_is('m4')
65 if not m4:
66 test.skip_test('M4 not found found; skipping test.\n')
68 test.file_fixture('wrapper.py')
70 test.write('SConstruct', """
71 DefaultEnvironment(tools=[])
72 foo = Environment(tools=['m4'],
73 M4=r'%(m4)s', M4FLAGS='-DFFF=fff')
74 m4 = foo.Dictionary('M4')
75 bar = Environment(tools=['m4'],
76 M4 = r'%(_python_)s wrapper.py ' + m4, M4FLAGS='-DBBB=bbb')
77 foo.M4(target = 'foo.x', source = 'foo.x.m4')
78 bar.M4(target = 'bar', source = 'bar.m4')
79 """ % locals())
81 test.write('foo.x.m4', os.linesep.join(["line 1", "FFF", "line 3"]))
83 test.write('bar.m4', os.linesep.join(["line 1", "BBB", "line 3"]))
85 test.run(arguments = '.')
86 test.up_to_date(arguments = '.')
88 test.must_match('wrapper.out', "wrapper.py\n")
90 test.must_match('foo.x', os.linesep.join(["line 1", "fff", "line 3"]))
92 test.must_match('bar', os.linesep.join(["line 1", "bbb", "line 3"]))
94 test.pass_test()
96 # Local Variables:
97 # tab-width:4
98 # indent-tabs-mode:nil
99 # End:
100 # vim: set expandtab tabstop=4 shiftwidth=4: