Fix vc9.0 express issue, misspelling, and add testcase which would have exposed the...
[scons.git] / test / Touch.py
index 7a3ca19979587e24bd9ad1bd5d4d7c6185213f55..7c1817ae6912674e289c1d29bfd938600b6ceba4 100644 (file)
@@ -36,12 +36,12 @@ test = TestSCons.TestSCons()
 
 test.write('SConstruct', """
 Execute(Touch('f1'))
+Execute(Touch(File('f1-File')))
 def cat(env, source, target):
     target = str(target[0])
-    source = map(str, source)
     f = open(target, "wb")
     for src in source:
-        f.write(open(src, "rb").read())
+        f.write(open(str(src), "rb").read())
     f.close()
 Cat = Action(cat)
 env = Environment()
@@ -51,31 +51,48 @@ env.Command('f5.out', 'f5.in', [Touch("$FILE"), Cat])
 env.Command('f6.out', 'f6.in', [Cat,
                                 Touch("Touch-$SOURCE"),
                                 Touch("$TARGET-Touch")])
+
+# Make sure Touch works with a list of arguments
+env = Environment()
+env.Command('f7.out', 'f7.in', [Cat,
+                                Touch(["Touch-$SOURCE",
+                                       "$TARGET-Touch",
+                                       File("f8")])])
 """)
 
 test.write('f1', "f1\n")
+test.write('f1-File', "f1-File\n")
 test.write('f2.in', "f2.in\n")
 test.write('f5.in', "f5.in\n")
 test.write('f6.in', "f6.in\n")
+test.write('f7.in', "f7.in\n")
 
-oldtime = os.path.getmtime(test.workpath('f1'))
+old_f1_time = os.path.getmtime(test.workpath('f1'))
+old_f1_File_time = os.path.getmtime(test.workpath('f1-File'))
 
-expect = test.wrap_stdout(read_str = 'Touch("f1")\n',
+expect = test.wrap_stdout(read_str = """\
+Touch("f1")
+Touch("f1-File")
+""",
                           build_str = """\
-cat("f2.out", "f2.in")
+cat(["f2.out"], ["f2.in"])
 Touch("f3")
 Touch("f4")
-cat("f5.out", "f5.in")
-cat("f6.out", "f6.in")
+cat(["f5.out"], ["f5.in"])
+cat(["f6.out"], ["f6.in"])
 Touch("Touch-f6.in")
 Touch("f6.out-Touch")
+cat(["f7.out"], ["f7.in"])
+Touch(["Touch-f7.in", "f7.out-Touch", "f8"])
 """)
 test.run(options = '-n', arguments = '.', stdout = expect)
 
 test.sleep(2)
 
-newtime = os.path.getmtime(test.workpath('f1'))
-test.fail_test(oldtime != newtime)
+new_f1_time = os.path.getmtime(test.workpath('f1'))
+test.fail_test(old_f1_time != new_f1_time)
+new_f1_File_time = os.path.getmtime(test.workpath('f1-File'))
+test.fail_test(old_f1_File_time != new_f1_File_time)
 
 test.must_not_exist(test.workpath('f2.out'))
 test.must_not_exist(test.workpath('f3'))
@@ -84,11 +101,17 @@ test.must_not_exist(test.workpath('f5.out'))
 test.must_not_exist(test.workpath('f6.out'))
 test.must_not_exist(test.workpath('Touch-f6.in'))
 test.must_not_exist(test.workpath('f6.out-Touch'))
+test.must_not_exist(test.workpath('f7.out'))
+test.must_not_exist(test.workpath('Touch-f7.in'))
+test.must_not_exist(test.workpath('f7.out-Touch'))
+test.must_not_exist(test.workpath('f8'))
 
 test.run()
 
-newtime = os.path.getmtime(test.workpath('f1'))
-test.fail_test(oldtime == newtime)
+new_f1_time = os.path.getmtime(test.workpath('f1'))
+test.fail_test(old_f1_time == new_f1_time)
+new_f1_File_time = os.path.getmtime(test.workpath('f1-File'))
+test.fail_test(old_f1_File_time == new_f1_File_time)
 
 test.must_match('f2.out', "f2.in\n")
 test.must_exist(test.workpath('f3'))
@@ -97,5 +120,15 @@ test.must_match('f5.out', "f5.in\n")
 test.must_match('f6.out', "f6.in\n")
 test.must_exist(test.workpath('Touch-f6.in'))
 test.must_exist(test.workpath('f6.out-Touch'))
+test.must_match('f7.out', "f7.in\n")
+test.must_exist(test.workpath('Touch-f7.in'))
+test.must_exist(test.workpath('f7.out-Touch'))
+test.must_exist(test.workpath('f8'))
 
 test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: