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.
29 _python_
= TestSCons
._python
_
32 test
= TestSCons
.TestSCons()
34 test
.file_fixture('mylink.py')
35 test
.dir_fixture('CXX-fixture')
37 test
.write('SConstruct', """
39 LINK=r'%(_python_)s mylink.py',
41 CXX=r'%(_python_)s myc++.py',
44 env.Program(target='test1', source='test1.cc')
45 env.Program(target='test2', source='test2.cpp')
46 env.Program(target='test3', source='test3.cxx')
47 env.Program(target='test4', source='test4.c++')
48 env.Program(target='test5', source='test5.C++')
51 test
.write('test1.cc', r
"""This is a .cc file.
56 test
.write('test2.cpp', r
"""This is a .cpp file.
61 test
.write('test3.cxx', r
"""This is a .cxx file.
66 test
.write('test4.c++', r
"""This is a .c++ file.
71 test
.write('test5.C++', r
"""This is a .C++ file.
76 test
.run(arguments
= '.', stderr
= None)
78 test
.must_match('test1' + _exe
, "This is a .cc file.\n", mode
='r')
80 test
.must_match('test2' + _exe
, "This is a .cpp file.\n", mode
='r')
82 test
.must_match('test3' + _exe
, "This is a .cxx file.\n", mode
='r')
84 test
.must_match('test4' + _exe
, "This is a .c++ file.\n", mode
='r')
86 test
.must_match('test5' + _exe
, "This is a .C++ file.\n", mode
='r')
88 if TestSCons
.case_sensitive_suffixes('.c', '.C'):
89 test
.write('SConstruct', """
91 LINK=r'%(_python_)s mylink.py',
93 CXX=r'%(_python_)s myc++.py',
96 env.Program(target='test6', source='test6.C')
99 test
.write('test6.C', r
"""This is a .C file.
104 test
.run(arguments
= '.', stderr
= None)
105 test
.must_match('test6' + _exe
, "This is a .C file.\n", mode
='r')
107 test
.file_fixture('wrapper.py')
109 test
.write('SConstruct', """
111 cxx = foo.Dictionary('CXX')
112 bar = Environment(CXX=r'%(_python_)s wrapper.py ' + cxx)
113 foo.Program(target='foo', source='foo.cxx')
114 bar.Program(target='bar', source='bar.cxx')
117 test
.write('foo.cxx', r
"""
121 main(int argc, char *argv[])
123 argv[argc++] = (char *)"--";
129 test
.write('bar.cxx', r
"""
133 main(int argc, char *argv[])
135 argv[argc++] = (char *)"--";
142 test
.run(arguments
= 'foo' + _exe
)
144 test
.must_not_exist(test
.workpath('wrapper.out'))
146 test
.run(arguments
= 'bar' + _exe
)
148 test
.must_match('wrapper.out', "wrapper.py\n", mode
='r')
154 # indent-tabs-mode:nil
156 # vim: set expandtab tabstop=4 shiftwidth=4: