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 that the Touch() Action works.
35 test = TestSCons.TestSCons()
37 test.write('SConstruct', """
39 Execute(Touch(File('f1-File')))
40 def cat(env, source, target):
41 target = str(target[0])
42 source = map(str, source)
43 f = open(target, "wb")
45 f.write(open(src, "rb").read())
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,
53 Touch("Touch-$SOURCE"),
54 Touch("$TARGET-Touch")])
56 # Make sure Touch works with a list of arguments
58 env.Command('f7.out', 'f7.in', [Cat,
59 Touch(["Touch-$SOURCE",
64 test.write('f1', "f1\n")
65 test.write('f1-File', "f1-File\n")
66 test.write('f2.in', "f2.in\n")
67 test.write('f5.in', "f5.in\n")
68 test.write('f6.in', "f6.in\n")
69 test.write('f7.in', "f7.in\n")
71 old_f1_time = os.path.getmtime(test.workpath('f1'))
72 old_f1_File_time = os.path.getmtime(test.workpath('f1-File'))
74 expect = test.wrap_stdout(read_str = """\
79 cat(["f2.out"], ["f2.in"])
82 cat(["f5.out"], ["f5.in"])
83 cat(["f6.out"], ["f6.in"])
86 cat(["f7.out"], ["f7.in"])
87 Touch(["Touch-f7.in", "f7.out-Touch", "f8"])
89 test.run(options = '-n', arguments = '.', stdout = expect)
93 new_f1_time = os.path.getmtime(test.workpath('f1'))
94 test.fail_test(old_f1_time != new_f1_time)
95 new_f1_File_time = os.path.getmtime(test.workpath('f1-File'))
96 test.fail_test(old_f1_File_time != new_f1_File_time)
98 test.must_not_exist(test.workpath('f2.out'))
99 test.must_not_exist(test.workpath('f3'))
100 test.must_not_exist(test.workpath('f4'))
101 test.must_not_exist(test.workpath('f5.out'))
102 test.must_not_exist(test.workpath('f6.out'))
103 test.must_not_exist(test.workpath('Touch-f6.in'))
104 test.must_not_exist(test.workpath('f6.out-Touch'))
105 test.must_not_exist(test.workpath('f7.out'))
106 test.must_not_exist(test.workpath('Touch-f7.in'))
107 test.must_not_exist(test.workpath('f7.out-Touch'))
108 test.must_not_exist(test.workpath('f8'))
112 new_f1_time = os.path.getmtime(test.workpath('f1'))
113 test.fail_test(old_f1_time == new_f1_time)
114 new_f1_File_time = os.path.getmtime(test.workpath('f1-File'))
115 test.fail_test(old_f1_File_time == new_f1_File_time)
117 test.must_match('f2.out', "f2.in\n")
118 test.must_exist(test.workpath('f3'))
119 test.must_exist(test.workpath('f4'))
120 test.must_match('f5.out', "f5.in\n")
121 test.must_match('f6.out', "f6.in\n")
122 test.must_exist(test.workpath('Touch-f6.in'))
123 test.must_exist(test.workpath('f6.out-Touch'))
124 test.must_match('f7.out', "f7.in\n")
125 test.must_exist(test.workpath('Touch-f7.in'))
126 test.must_exist(test.workpath('f7.out-Touch'))
127 test.must_exist(test.workpath('f8'))
133 # indent-tabs-mode:nil
135 # vim: set expandtab tabstop=4 shiftwidth=4: