Merged revisions 2527-2645 via svnmerge from
[scons.git] / test / Deprecated / SourceSignatures / env.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Test that use of env.SourceSignatures() correctly overrides the
29 default behavior.
30 """
31
32 import os
33 import os.path
34 import re
35
36 import TestSCons
37
38 test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
39
40 base_sconstruct_contents = """\
41 SetOption('warn', 'no-deprecated-source-signatures')
42 def build(env, target, source):
43     open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
44 B = Builder(action = build)
45 env = Environment(BUILDERS = { 'B' : B })
46 env2 = env.Clone()
47 env2.SourceSignatures('%s')
48 env.B(target = 'f1.out', source = 'f1.in')
49 env.B(target = 'f2.out', source = 'f2.in')
50 env2.B(target = 'f3.out', source = 'f3.in')
51 env2.B(target = 'f4.out', source = 'f4.in')
52
53 SourceSignatures('%s')
54 """
55
56 def write_SConstruct(test, env_sigtype, default_sigtype):
57     contents = base_sconstruct_contents % (env_sigtype, default_sigtype)
58     test.write('SConstruct', contents)
59
60
61
62 write_SConstruct(test, 'MD5', 'timestamp')
63
64 test.write('f1.in', "f1.in\n")
65 test.write('f2.in', "f2.in\n")
66 test.write('f3.in', "f3.in\n")
67 test.write('f4.in', "f4.in\n")
68
69 test.run(arguments = 'f1.out f3.out',
70          stderr = TestSCons.deprecated_python_expr)
71
72 test.run(arguments = 'f1.out f2.out f3.out f4.out',
73          stdout = re.escape(test.wrap_stdout("""\
74 scons: `f1.out' is up to date.
75 build(["f2.out"], ["f2.in"])
76 scons: `f3.out' is up to date.
77 build(["f4.out"], ["f4.in"])
78 """)),
79          stderr = TestSCons.deprecated_python_expr)
80
81
82
83 test.sleep()
84
85 test.touch('f1.in')
86 test.touch('f3.in')
87
88 test.run(arguments = 'f1.out f2.out f3.out f4.out',
89          stdout = re.escape(test.wrap_stdout("""\
90 build(["f1.out"], ["f1.in"])
91 scons: `f2.out' is up to date.
92 scons: `f3.out' is up to date.
93 scons: `f4.out' is up to date.
94 """)),
95          stderr = TestSCons.deprecated_python_expr)
96
97 test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
98
99
100
101 test.pass_test()