Support construction variable expansion anywhere in a file or path name.
[scons.git] / test / SetContentSignatureType.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 import imp
28 import os
29 import os.path
30
31 import TestSCons
32
33 test = TestSCons.TestSCons()
34
35 warning = """\
36
37 scons: warning: The SetContentSignatureType() function has been deprecated;
38         use the SourceSignatures() function instead.
39 File "SConstruct", line %d, in ?
40 """
41
42 test.write('SConstruct', """
43 def build(env, target, source):
44     open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
45 B = Builder(action = build)
46 env = Environment(BUILDERS = { 'B' : B })
47 env.B(target = 'f1.out', source = 'f1.in')
48 env.B(target = 'f2.out', source = 'f2.in')
49 env.B(target = 'f3.out', source = 'f3.in')
50 env.B(target = 'f4.out', source = 'f4.in')
51
52 SetContentSignatureType('timestamp')
53 """)
54
55 test.write('f1.in', "f1.in\n")
56 test.write('f2.in', "f2.in\n")
57 test.write('f3.in', "f3.in\n")
58 test.write('f4.in', "f4.in\n")
59
60 test.run(arguments = 'f1.out f3.out',
61          stderr = warning%11)
62
63 test.run(arguments = 'f1.out f2.out f3.out f4.out',
64          stdout = test.wrap_stdout("""\
65 scons: `f1.out' is up to date.
66 build("f2.out", "f2.in")
67 scons: `f3.out' is up to date.
68 build("f4.out", "f4.in")
69 """),
70          stderr = warning%11)
71
72 os.utime(test.workpath('f1.in'), 
73          (os.path.getatime(test.workpath('f1.in')),
74           os.path.getmtime(test.workpath('f1.in'))+10))
75 os.utime(test.workpath('f3.in'), 
76          (os.path.getatime(test.workpath('f3.in')),
77           os.path.getmtime(test.workpath('f3.in'))+10))
78
79 test.run(arguments = 'f1.out f2.out f3.out f4.out',
80          stdout = test.wrap_stdout("""\
81 build("f1.out", "f1.in")
82 scons: `f2.out' is up to date.
83 build("f3.out", "f3.in")
84 scons: `f4.out' is up to date.
85 """),
86          stderr = warning%11)
87
88 test.write('SConstruct', """
89 def build(env, target, source):
90     open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
91 B = Builder(action = build)
92 env = Environment(BUILDERS = { 'B' : B })
93 env.B(target = 'f1.out', source = 'f1.in')
94 env.B(target = 'f2.out', source = 'f2.in')
95 env.B(target = 'f3.out', source = 'f3.in')
96 env.B(target = 'f4.out', source = 'f4.in')
97
98 SetContentSignatureType('MD5')
99 """)
100
101 test.write('f1.in', "f1.in\n")
102 test.write('f2.in', "f2.in\n")
103 test.write('f3.in', "f3.in\n")
104 test.write('f4.in', "f4.in\n")
105
106 test.run(arguments = 'f1.out f3.out',
107          stderr = warning%11)
108
109 test.run(arguments = 'f1.out f2.out f3.out f4.out',
110          stdout = test.wrap_stdout("""\
111 scons: `f1.out' is up to date.
112 build("f2.out", "f2.in")
113 scons: `f3.out' is up to date.
114 build("f4.out", "f4.in")
115 """),
116          stderr = warning%11)
117
118 os.utime(test.workpath('f1.in'), 
119          (os.path.getatime(test.workpath('f1.in')),
120           os.path.getmtime(test.workpath('f1.in'))+10))
121 os.utime(test.workpath('f3.in'), 
122          (os.path.getatime(test.workpath('f3.in')),
123           os.path.getmtime(test.workpath('f3.in'))+10))
124
125 test.run(arguments = 'f1.out f2.out f3.out f4.out',
126          stdout = test.wrap_stdout("""\
127 scons: `f1.out' is up to date.
128 scons: `f2.out' is up to date.
129 scons: `f3.out' is up to date.
130 scons: `f4.out' is up to date.
131 """),
132          stderr = warning%11)
133
134 test.write('SConstruct', """
135 def build(env, target, source):
136     open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
137 B = Builder(action = build)
138 env = Environment(BUILDERS = { 'B' : B })
139 env.B(target = 'f1.out', source = 'f1.in')
140 env.B(target = 'f2.out', source = 'f2.in')
141 env.B(target = 'f3.out', source = 'f3.in')
142 env.B(target = 'f4.out', source = 'f4.in')
143 """)
144
145 test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out')
146
147 test.pass_test()
148
149 test.write('SConstruct', """
150 def build(env, target, source):
151     open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
152 B = Builder(action = build)
153 env = Environment(BUILDERS = { 'B' : B })
154 env.B(target = 'f1.out', source = 'f1.in')
155 env.B(target = 'f2.out', source = 'f2.in')
156 env.B(target = 'f3.out', source = 'f3.in')
157 env.B(target = 'f4.out', source = 'f4.in')
158
159 SetContentSignatureType('timestamp')
160 """)
161
162 test.run(arguments = 'f1.out f2.out f3.out f4.out',
163          stdout = test.wrap_stdout(''),
164          stderr = warning%11)