added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / DSUFFIXES.py
blob54a506ccb1ffecf53b34b623fd6837e5500b918b
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 the ability to scan additional filesuffixes added to $DSUFFIXES.
29 """
31 import TestSCons
33 _python_ = TestSCons._python_
35 test = TestSCons.TestSCons()
37 test.write('mydc.py', r"""
38 import sys
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')
44 else:
45 outf.write(line)
46 with open(sys.argv[1], 'wb') as outf:
47 for f in sys.argv[2:]:
48 do_file(outf, f)
49 sys.exit(0)
50 """)
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.
56 env = Environment()
57 Tool('dmd')(env)
58 # Now replace those suffixes with our fake-D things.
59 env.Replace(DPATH = ['.'],
60 DC = r'%(_python_)s mydc.py',
61 DFLAGS = [],
62 DCOM = '$DC $TARGET $SOURCES',
63 OBJSUFFIX = '.o')
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')
69 """ % locals())
71 test.write('test1.d', """\
72 test1.d 1
73 import test2;
74 import test3;
75 """)
77 test.write('test2.d', """\
78 test2.d 1
79 import foo;
80 """)
82 test.write('test3.d', """\
83 test3.d 1
84 import foo;
85 """)
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"
94 """ % locals())
96 test.run(arguments='.', stdout=expect)
98 test.must_match('test1.o', """\
99 test1.d 1
100 test2.d 1
101 foo.d 1
102 test3.d 1
103 foo.d 1
104 """)
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
112 """ % locals())
114 test.run(arguments='.', stdout=expect)
116 test.must_match('test1.o', """\
117 test1.d 1
118 test2.d 1
119 foo.d 2
120 test3.d 1
121 foo.d 2
122 """)
124 test.up_to_date(arguments='.')
126 test.write('test3.d', """\
127 test3.d 2
128 import foo;
129 """)
131 expect = test.wrap_stdout("""\
132 %(_python_)s mydc.py test1.o test1.d
133 Install file: "test3.d" as "test3_d"
134 """ % locals())
136 test.run(arguments='.', stdout=expect)
138 test.must_match('test1.o', """\
139 test1.d 1
140 test2.d 1
141 foo.d 2
142 test3.d 2
143 foo.d 2
144 """)
146 test.up_to_date(arguments='.')
148 test.write('test2.d', """\
149 test2.d 2
150 import foo;
151 """)
153 expect = test.wrap_stdout("""\
154 %(_python_)s mydc.py test1.o test1.d
155 Install file: "test2.d" as "test2_d"
156 """ % locals())
158 test.run(arguments='.', stdout=expect)
160 test.must_match('test1.o', """\
161 test1.d 1
162 test2.d 2
163 foo.d 2
164 test3.d 2
165 foo.d 2
166 """)
168 test.up_to_date(arguments='.')
170 test.pass_test()
172 # Local Variables:
173 # tab-width:4
174 # indent-tabs-mode:nil
175 # End:
176 # vim: set expandtab tabstop=4 shiftwidth=4: