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.
27 Test setting the YACC_GRAPH_FILE_SUFFIX variable.
28 Also that if both YACCVCGFILESUFFIX and YACC_GRAPH_FILE_SUFFIX are set,
29 then YACCVCGFILESUFFIX will be ignored.
34 _python_
= TestSCons
._python
_
36 test
= TestSCons
.TestSCons()
38 test
.write('myyacc.py', """\
44 opts, args = getopt.getopt(sys.argv[1:], 'go:')
49 outfile = open(a, 'wb')
51 with open(f, 'rb') as infile:
52 for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
56 base, ext = os.path.splitext(args[0])
57 with open(base + '.graph_suffix', 'wb') as outfile:
58 outfile.write((" ".join(sys.argv) + '\\n').encode())
62 test
.write('SConstruct', """
63 DefaultEnvironment(tools=[])
65 tools=['default', 'yacc'],
66 YACC=r'%(_python_)s myyacc.py',
67 YACCVCGFILESUFFIX='.vcg_obsolete',
68 YACC_GRAPH_FILE_SUFFIX='.graph_suffix',
70 env.CXXFile(target='aaa', source='aaa.yy')
71 env.CXXFile(target='bbb', source='bbb.yy', YACCFLAGS='-g')
74 test
.write('aaa.yy', "aaa.yy\n/*yacc*/\n")
75 test
.write('bbb.yy', "bbb.yy\n/*yacc*/\n")
77 test
.run(arguments
='.')
79 test
.must_match('aaa.cc', "aaa.yy\n")
80 test
.must_not_exist('aaa.vcg')
81 test
.must_not_exist('aaa.graph_suffix')
83 test
.must_match('bbb.cc', "bbb.yy\n")
84 test
.must_not_exist('bbb.vcg')
85 test
.must_not_exist('bbb.vcg_obsolete')
86 test
.must_contain('bbb.graph_suffix', "myyacc.py -g -o bbb.cc bbb.yy\n")
88 test
.up_to_date(arguments
='.')
94 # indent-tabs-mode:nil
96 # vim: set expandtab tabstop=4 shiftwidth=4: