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.
27 Verify that the Touch() Action works.
34 test
= TestSCons
.TestSCons()
36 test
.write('SConstruct', """\
38 Execute(Touch(File('f1-File')))
40 def cat(env, source, target):
41 target = str(target[0])
42 with open(target, "wb") as f:
44 with open(str(src), "rb") as ifp:
49 env.Command('f2.out', 'f2.in', [Cat, Touch("f3")])
50 env = Environment(FILE='f4')
51 env.Command('f5.out', 'f5.in', [Touch("$FILE"), Cat])
52 env.Command('f6.out', 'f6.in', [Cat, Touch("Touch-$SOURCE"), Touch("$TARGET-Touch")])
54 # Make sure Touch works with a list of arguments
57 'f7.out', 'f7.in', [Cat, Touch(["Touch-$SOURCE", "$TARGET-Touch", File("f8")])]
61 test
.write('f1', "f1\n")
62 test
.write('f1-File', "f1-File\n")
63 test
.write('f2.in', "f2.in\n")
64 test
.write('f5.in', "f5.in\n")
65 test
.write('f6.in', "f6.in\n")
66 test
.write('f7.in', "f7.in\n")
68 old_f1_time
= os
.path
.getmtime(test
.workpath('f1'))
69 old_f1_File_time
= os
.path
.getmtime(test
.workpath('f1-File'))
71 expect
= test
.wrap_stdout(
77 cat(["f2.out"], ["f2.in"])
80 cat(["f5.out"], ["f5.in"])
81 cat(["f6.out"], ["f6.in"])
84 cat(["f7.out"], ["f7.in"])
85 Touch(["Touch-f7.in", "f7.out-Touch", "f8"])
88 test
.run(options
='-n', arguments
='.', stdout
=expect
)
90 test
.sleep() # delay for timestamps
91 new_f1_time
= os
.path
.getmtime(test
.workpath('f1'))
92 test
.fail_test(old_f1_time
!= new_f1_time
)
93 new_f1_File_time
= os
.path
.getmtime(test
.workpath('f1-File'))
94 test
.fail_test(old_f1_File_time
!= new_f1_File_time
)
96 test
.must_not_exist(test
.workpath('f2.out'))
97 test
.must_not_exist(test
.workpath('f3'))
98 test
.must_not_exist(test
.workpath('f4'))
99 test
.must_not_exist(test
.workpath('f5.out'))
100 test
.must_not_exist(test
.workpath('f6.out'))
101 test
.must_not_exist(test
.workpath('Touch-f6.in'))
102 test
.must_not_exist(test
.workpath('f6.out-Touch'))
103 test
.must_not_exist(test
.workpath('f7.out'))
104 test
.must_not_exist(test
.workpath('Touch-f7.in'))
105 test
.must_not_exist(test
.workpath('f7.out-Touch'))
106 test
.must_not_exist(test
.workpath('f8'))
110 new_f1_time
= os
.path
.getmtime(test
.workpath('f1'))
111 test
.fail_test(old_f1_time
== new_f1_time
)
112 new_f1_File_time
= os
.path
.getmtime(test
.workpath('f1-File'))
113 test
.fail_test(old_f1_File_time
== new_f1_File_time
)
115 test
.must_match('f2.out', "f2.in\n")
116 test
.must_exist(test
.workpath('f3'))
117 test
.must_exist(test
.workpath('f4'))
118 test
.must_match('f5.out', "f5.in\n")
119 test
.must_match('f6.out', "f6.in\n")
120 test
.must_exist(test
.workpath('Touch-f6.in'))
121 test
.must_exist(test
.workpath('f6.out-Touch'))
122 test
.must_match('f7.out', "f7.in\n")
123 test
.must_exist(test
.workpath('Touch-f7.in'))
124 test
.must_exist(test
.workpath('f7.out-Touch'))
125 test
.must_exist(test
.workpath('f8'))
131 # indent-tabs-mode:nil
133 # vim: set expandtab tabstop=4 shiftwidth=4: