[ci skip] update generated files
[scons.git] / test / Decider / MD5-timestamp.py
blob3815639672e1459a3b4e5195e67efc594313bd70
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 """
27 Verify behavior of the MD5-timestamp Decider() setting.
28 """
30 import os
31 import stat
33 import TestSCons
35 test = TestSCons.TestSCons()
37 test.write('SConstruct', """\
38 DefaultEnvironment(tools=[])
39 m = Environment(tools=[])
40 m.Decider('MD5-timestamp')
41 m.Command('content1.out', 'content1.in', Copy('$TARGET', '$SOURCE'))
42 m.Command('content2.out', 'content2.in', Copy('$TARGET', '$SOURCE'))
43 m.Command('content3.out', 'content3.in', Copy('$TARGET', '$SOURCE'))
44 """)
46 test.write('content1.in', "content1.in 1\n")
47 test.write('content2.in', "content2.in 1\n")
48 test.write('content3.in', "content3.in 1\n")
50 test.run(arguments = '.')
51 test.up_to_date(arguments = '.')
53 test.sleep() # delay for timestamps
54 test.write('content1.in', "content1.in 2\n")
55 test.touch('content2.in')
57 time_content = os.stat('content3.in')[stat.ST_MTIME]
58 test.write('content3.in', "content3.in 2\n")
59 test.touch('content3.in', time_content)
61 # We should only see content1.out rebuilt. The timestamp of content2.in
62 # has changed, but its content hasn't, so the follow-on content check says
63 # to not rebuild it. The content of content3.in has changed, but that's
64 # masked by the fact that its timestamp is the same as the last run.
66 expect = test.wrap_stdout("""\
67 Copy("content1.out", "content1.in")
68 """)
70 test.run(arguments='.', stdout=expect)
71 test.up_to_date(arguments='.')
73 test.pass_test()
75 # Local Variables:
76 # tab-width:4
77 # indent-tabs-mode:nil
78 # End:
79 # vim: set expandtab tabstop=4 shiftwidth=4: