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__"
28 Test the ability to scan additional filesuffixes added to $DSUFFIXES.
33 _python_
= TestSCons
._python
_
35 test
= TestSCons
.TestSCons()
37 test
.write('mydc.py', r
"""
39 def do_file(outf, inf):
40 with open(inf, 'rb') as ifp:
41 for line in ifp.readlines():
42 if line[:7] == b'import ':
43 do_file(outf, line[7:-2] + b'.d')
46 with open(sys.argv[1], 'wb') as outf:
47 for f in sys.argv[2:]:
52 test
.write('SConstruct', """
53 # Force the 'dmd' tool to get added to the Environment, even if it's not
54 # installed, so we get its definition of variables to deal with turning
55 # '.d' suffix files into objects.
58 # Now replace those suffixes with our fake-D things.
59 env.Replace(DPATH = ['.'],
60 DC = r'%(_python_)s mydc.py',
62 DCOM = '$DC $TARGET $SOURCES',
64 env.Append(CPPSUFFIXES = ['.x'])
65 env.Object(target = 'test1', source = 'test1.d')
66 env.InstallAs('test1_d', 'test1.d')
67 env.InstallAs('test2_d', 'test2.d')
68 env.InstallAs('test3_d', 'test3.d')
71 test
.write('test1.d', """\
77 test
.write('test2.d', """\
82 test
.write('test3.d', """\
87 test
.write('foo.d', "foo.d 1\n")
89 expect
= test
.wrap_stdout("""\
90 %(_python_)s mydc.py test1.o test1.d
91 Install file: "test1.d" as "test1_d"
92 Install file: "test2.d" as "test2_d"
93 Install file: "test3.d" as "test3_d"
96 test
.run(arguments
='.', stdout
=expect
)
98 test
.must_match('test1.o', """\
106 test
.up_to_date(arguments
='.')
108 test
.write('foo.d', "foo.d 2\n")
110 expect
= test
.wrap_stdout("""\
111 %(_python_)s mydc.py test1.o test1.d
114 test
.run(arguments
='.', stdout
=expect
)
116 test
.must_match('test1.o', """\
124 test
.up_to_date(arguments
='.')
126 test
.write('test3.d', """\
131 expect
= test
.wrap_stdout("""\
132 %(_python_)s mydc.py test1.o test1.d
133 Install file: "test3.d" as "test3_d"
136 test
.run(arguments
='.', stdout
=expect
)
138 test
.must_match('test1.o', """\
146 test
.up_to_date(arguments
='.')
148 test
.write('test2.d', """\
153 expect
= test
.wrap_stdout("""\
154 %(_python_)s mydc.py test1.o test1.d
155 Install file: "test2.d" as "test2_d"
158 test
.run(arguments
='.', stdout
=expect
)
160 test
.must_match('test1.o', """\
168 test
.up_to_date(arguments
='.')
174 # indent-tabs-mode:nil
176 # vim: set expandtab tabstop=4 shiftwidth=4: