[ci skip] update generated files
[scons.git] / test / LEX / LEX.py
blob3eb7960b1b092b534925d264fc022f023b5b6f56
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 import TestSCons
28 _python_ = TestSCons._python_
29 _exe = TestSCons._exe
31 test = TestSCons.TestSCons()
33 test.file_fixture('mylex.py')
35 test.write('SConstruct', """
36 DefaultEnvironment(tools=[])
37 env = Environment(LEX=r'%(_python_)s mylex.py', tools=['default', 'lex'])
38 env.CFile(target='aaa', source='aaa.l')
39 env.CFile(target='bbb', source='bbb.lex')
40 env.CXXFile(target='ccc', source='ccc.ll')
41 env.CXXFile(target='ddd', source='ddd.lm')
42 """ % locals())
44 test.write('aaa.l', "aaa.l\nLEX\n")
45 test.write('bbb.lex', "bbb.lex\nLEX\n")
46 test.write('ccc.ll', "ccc.ll\nLEX\n")
47 test.write('ddd.lm', "ddd.lm\nLEX\n")
49 test.run(arguments='.', stderr=None)
51 # Read in with mode='r' because mylex.py implicitley wrote to stdout
52 # with mode='w'.
53 test.must_match('aaa.c', "aaa.l\nmylex.py\n", mode='r')
54 test.must_match('bbb.c', "bbb.lex\nmylex.py\n", mode='r')
55 test.must_match('ccc.cc', "ccc.ll\nmylex.py\n", mode='r')
56 test.must_match('ddd.m', "ddd.lm\nmylex.py\n", mode='r')
58 test.pass_test()
60 # Local Variables:
61 # tab-width:4
62 # indent-tabs-mode:nil
63 # End:
64 # vim: set expandtab tabstop=4 shiftwidth=4: