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__"
28 Verify falling back to 'timestamp' behavior if there is no md5
29 module. Formerly checked for hashlib first, but that has been
30 standard library since 2.5; test is kept in case one of those
31 rare no-md5 Pythons comes into play (some entities ban the use
32 of md5 as unsafe, although SCons does not use it in a security context.
39 test
= TestSCons
.TestSCons()
42 from hashlib
import md5
46 msg
= "The 'md5' algorithm is built in to hashlib in this version of Python.\n" + \
47 "Cannot test falling back to timestamps.\n"
50 test
.write('md5.py', r
"""
54 os
.environ
['PYTHONPATH'] = test
.workpath('.')
56 test
.write('SConstruct', """
57 DefaultEnvironment(tools=[])
59 def build(env, target, source):
60 with open(str(target[0]), 'wt') as ofp, open(str(source[0]), 'rt') as ifp:
63 B = Builder(action = build)
64 env = Environment(tools = [], BUILDERS = { 'B' : B })
65 env.B(target = 'f1.out', source = 'f1.in')
66 env.B(target = 'f2.out', source = 'f2.in')
67 env.B(target = 'f3.out', source = 'f3.in')
68 env.B(target = 'f4.out', source = 'f4.in')
71 test
.write('f1.in', "f1.in\n")
72 test
.write('f2.in', "f2.in\n")
73 test
.write('f3.in', "f3.in\n")
74 test
.write('f4.in', "f4.in\n")
76 test
.run(arguments
= 'f1.out f3.out',
79 test
.run(arguments
= 'f1.out f2.out f3.out f4.out',
80 stdout
= test
.wrap_stdout("""\
81 scons: `f1.out' is up to date.
82 build(["f2.out"], ["f2.in"])
83 scons: `f3.out' is up to date.
84 build(["f4.out"], ["f4.in"])
88 os
.utime(test
.workpath('f1.in'),
89 (os
.path
.getatime(test
.workpath('f1.in')),
90 os
.path
.getmtime(test
.workpath('f1.in'))+10))
91 os
.utime(test
.workpath('f3.in'),
92 (os
.path
.getatime(test
.workpath('f3.in')),
93 os
.path
.getmtime(test
.workpath('f3.in'))+10))
95 test
.run(arguments
= 'f1.out f2.out f3.out f4.out',
96 stdout
= test
.wrap_stdout("""\
97 build(["f1.out"], ["f1.in"])
98 scons: `f2.out' is up to date.
99 build(["f3.out"], ["f3.in"])
100 scons: `f4.out' is up to date.
109 # indent-tabs-mode:nil
111 # vim: set expandtab tabstop=4 shiftwidth=4: