Merge pull request #4655 from bdbaddog/fix_new_ninja_package
[scons.git] / test / Removed / TargetSignatures / Old / build-content.py
blobefdaaeedd3aa986e54d3f37cd1ad3aab1e7213b5
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 basic interaction of the historic TargetSignatures('build')
29 and TargetSignatures('content') settings, overriding one with
30 the other in specific construction environments.
31 """
33 import re
35 import TestSCons
37 test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
39 expect = TestSCons.re_escape("""
40 scons: warning: The env.TargetSignatures() method is deprecated;
41 \tconvert your build to use the env.Decider() method instead.
42 """) + TestSCons.file_expr
45 sconstruct_contents = """\
46 SetOption('warn', 'deprecated-target-signatures')
47 env = Environment()
49 def copy1(env, source, target):
50 with open(str(target[0]), 'wb') as fo, open(str(source[0]), 'rb') as fi:
51 fo.write(fi.read())
53 def copy2(env, source, target):
55 return copy1(env, source, target)
57 env['BUILDERS']['Copy1'] = Builder(action=copy1)
58 env['BUILDERS']['Copy2'] = Builder(action=copy2)
60 env.Copy2('foo.mid', 'foo.in')
61 env.Copy1('foo.out', 'foo.mid')
63 env2 = env.Clone()
64 env2.TargetSignatures('%s')
65 env2.Copy2('bar.mid', 'bar.in')
66 env2.Copy1('bar.out', 'bar.mid')
68 TargetSignatures('%s')
69 """
71 def write_SConstruct(test, *args):
72 contents = sconstruct_contents % args
73 test.write('SConstruct', contents)
77 write_SConstruct(test, '', 'build', 'content')
79 test.write('foo.in', 'foo.in')
80 test.write('bar.in', 'bar.in')
82 test.run(arguments="bar.out foo.out",
83 stdout=re.escape(test.wrap_stdout("""\
84 copy2(["bar.mid"], ["bar.in"])
85 copy1(["bar.out"], ["bar.mid"])
86 copy2(["foo.mid"], ["foo.in"])
87 copy1(["foo.out"], ["foo.mid"])
88 """)),
89 stderr = expect)
91 test.up_to_date(arguments='bar.out foo.out', stderr=None)
95 # Change the code in the the copy2() function, which should change
96 # its content and trigger a rebuild of the targets built with it.
98 write_SConstruct(test, 'x = 2 # added this line', 'build', 'content')
100 test.run(arguments="bar.out foo.out",
101 stdout=re.escape(test.wrap_stdout("""\
102 copy2(["bar.mid"], ["bar.in"])
103 copy1(["bar.out"], ["bar.mid"])
104 copy2(["foo.mid"], ["foo.in"])
105 scons: `foo.out' is up to date.
106 """)),
107 stderr = expect)
111 # Swapping content and build signatures no longer causes a rebuild
112 # because we record the right underlying information regardless.
114 write_SConstruct(test, 'x = 2 # added this line', 'content', 'build')
116 test.up_to_date(arguments="bar.out foo.out", stderr=None)
120 # Change the code in the the copy2() function back again, which should
121 # trigger another rebuild of the targets built with it.
123 write_SConstruct(test, '', 'content', 'build')
125 test.run(arguments='bar.out foo.out',
126 stdout=re.escape(test.wrap_stdout("""\
127 copy2(["bar.mid"], ["bar.in"])
128 scons: `bar.out' is up to date.
129 copy2(["foo.mid"], ["foo.in"])
130 copy1(["foo.out"], ["foo.mid"])
131 """)),
132 stderr = expect)
136 test.pass_test()
138 # Local Variables:
139 # tab-width:4
140 # indent-tabs-mode:nil
141 # End:
142 # vim: set expandtab tabstop=4 shiftwidth=4: