Migrate LIBLITERALPREFIX test to file with same name
[scons.git] / test / Batch / generated.py
blob65ce8a855c01702aa522851b3f6c7ea4dab08f51
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 Verify use of a batch builder when one of the later targets in the
29 list the list depends on a generated file.
30 """
32 import TestSCons
34 test = TestSCons.TestSCons()
36 test.write('SConstruct', """
37 def batch_build(target, source, env):
38 for t, s in zip(target, source):
39 with open(str(t), 'wb') as fp:
40 if str(t) == 'f3.out':
41 with open('f3.include', 'rb') as f:
42 fp.write(f.read())
43 with open(str(s), 'rb') as f:
44 fp.write(f.read())
45 env = Environment()
46 bb = Action(batch_build, batch_key=True)
47 env['BUILDERS']['Batch'] = Builder(action=bb)
48 env1 = env.Clone()
49 env1.Batch('f1.out', 'f1.in')
50 env1.Batch('f2.out', 'f2.mid')
51 f3_out = env1.Batch('f3.out', 'f3.in')
53 env2 = env.Clone()
54 env2.Batch('f2.mid', 'f2.in')
56 f3_include = env.Batch('f3.include', 'f3.include.in')
57 env.Depends(f3_out, f3_include)
58 """)
60 test.write('f1.in', "f1.in\n")
61 test.write('f2.in', "f2.in\n")
62 test.write('f3.in', "f3.in\n")
63 test.write('f3.include.in', "f3.include.in\n")
65 expect = test.wrap_stdout("""\
66 batch_build(["f2.mid"], ["f2.in"])
67 batch_build(["f3.include"], ["f3.include.in"])
68 batch_build(["f1.out", "f2.out", "f3.out"], ["f1.in", "f2.mid", "f3.in"])
69 """)
71 test.run(stdout = expect)
73 test.must_match('f1.out', "f1.in\n")
74 test.must_match('f2.out', "f2.in\n")
76 test.up_to_date(arguments = '.')
78 test.pass_test()
80 # Local Variables:
81 # tab-width:4
82 # indent-tabs-mode:nil
83 # End:
84 # vim: set expandtab tabstop=4 shiftwidth=4: