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 def cat(env, source, target):
40 target = str(target[0])
41 source = map(str, source)
42 f = open(target, "wb")
44 f.write(open(src, "rb").read())
48 env.Command('f2.out', 'f2.in', [Cat, Touch("f3")])
49 env = Environment(FILE='f4')
50 env.Command('f5.out', 'f5.in', [Touch("$FILE"), Cat])
51 env.Command('f6.out', 'f6.in', [Cat,
52 Touch("Touch-$SOURCE"),
53 Touch("$TARGET-Touch")])
56 test.write('f1', "f1\n")
57 test.write('f2.in', "f2.in\n")
58 test.write('f5.in', "f5.in\n")
59 test.write('f6.in', "f6.in\n")
61 oldtime = os.path.getmtime(test.workpath('f1'))
63 expect = test.wrap_stdout(read_str = 'Touch("f1")\n',
65 cat("f2.out", "f2.in")
68 cat("f5.out", "f5.in")
69 cat("f6.out", "f6.in")
73 test.run(options = '-n', arguments = '.', stdout = expect)
77 newtime = os.path.getmtime(test.workpath('f1'))
78 test.fail_test(oldtime != newtime)
80 test.must_not_exist(test.workpath('f2.out'))
81 test.must_not_exist(test.workpath('f3'))
82 test.must_not_exist(test.workpath('f4'))
83 test.must_not_exist(test.workpath('f5.out'))
84 test.must_not_exist(test.workpath('f6.out'))
85 test.must_not_exist(test.workpath('Touch-f6.in'))
86 test.must_not_exist(test.workpath('f6.out-Touch'))
90 newtime = os.path.getmtime(test.workpath('f1'))
91 test.fail_test(oldtime == newtime)
93 test.must_match('f2.out', "f2.in\n")
94 test.must_exist(test.workpath('f3'))
95 test.must_exist(test.workpath('f4'))
96 test.must_match('f5.out', "f5.in\n")
97 test.must_match('f6.out', "f6.in\n")
98 test.must_exist(test.workpath('Touch-f6.in'))
99 test.must_exist(test.workpath('f6.out-Touch'))