Merge pull request #4674 from bdbaddog/fix_2281_Aliases_ignore_pre_post_add_actions
[scons.git] / test / Builder / multi / different-target-lists.py
blob4b6c49e723a47aac11baed8bf0a0725c1cd055e4
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 that a target file can't be in two different target lists.
29 """
31 # XXX It would be nice if the following two tests could be made to work
32 # by executing the action once for each unique set of targets. This
33 # would make it simple to deal with PDB files on Windows like so:
35 # env.Object(['foo.obj', 'vc60.pdb'], 'foo.c')
36 # env.Object(['bar.obj', 'vc60.pdb'], 'bar.c')
38 import TestSCons
40 test = TestSCons.TestSCons(match=TestSCons.match_re)
42 test.write('SConstruct', """\
43 DefaultEnvironment(tools=[])
44 def build(env, target, source):
45 for t in target:
46 with open(str(target[0]), 'wb') as f:
47 for s in source:
48 with open(str(s), 'rb') as infp:
49 f.write(infp.read())
51 B = Builder(action=build, multi=1)
52 env = Environment(tools=[], BUILDERS = { 'B' : B })
53 env.B(target = ['file11a.out', 'file11b.out'], source = 'file11a.in')
54 env.B(target = ['file11b.out', 'file11c.out'], source = 'file11b.in')
55 """)
57 test.write('file11a.in', 'file11a.in\n')
58 test.write('file11b.in', 'file11b.in\n')
60 expect = TestSCons.re_escape("""
61 scons: *** Two different target lists have a target in common: file11b.out (from ['file11a.out', 'file11b.out'] and from ['file11b.out', 'file11c.out'])
62 """) + TestSCons.file_expr
64 test.run(arguments='file11.out', status=2, stderr=expect)
66 test.pass_test()
68 # Local Variables:
69 # tab-width:4
70 # indent-tabs-mode:nil
71 # End:
72 # vim: set expandtab tabstop=4 shiftwidth=4: