Fix vc9.0 express issue, misspelling, and add testcase which would have exposed the...
[scons.git] / test / chdir.py
index e2d08949ffc4d0267d4932102528473fa0882cde..c4d392e3c4a193d9bfd1c0a00238424018882932 100644 (file)
@@ -31,7 +31,7 @@ Command() calls and execution work1s correctly.
 
 import TestSCons
 
-python = TestSCons.python
+_python_ = TestSCons._python_
 
 test = TestSCons.TestSCons()
 
@@ -91,14 +91,15 @@ other9_f19_in = test.workpath('other9', 'f19.in')
 
 test.write(cat_py, """\
 import sys
-ofp = open(sys.argv[1], 'w')
-for ifp in map(open, sys.argv[2:]):
+ofp = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+    ifp = open(f, 'rb')
     ofp.write(ifp.read())
 ofp.close
 """)
 
 test.write(['work1', 'SConstruct'], """
-cat_command = r"%(python)s %(cat_py)s ${TARGET.file} ${SOURCE.file}"
+cat_command = r'%(_python_)s %(cat_py)s ${TARGET.file} ${SOURCE.file}'
 
 no_chdir_act = Action(cat_command)
 chdir_sub4_act = Action(cat_command, chdir=1)
@@ -223,19 +224,19 @@ test.must_match(['work1', 'sub23', 'f23.out'], "work1/sub23/f23.in\n")
 test.subdir('work2',
             ['work2', 'sub'])
 
-work2 = test.workpath('work2')
+work2 = repr(test.workpath('work2'))
 work2_sub_f1_out = test.workpath('work2', 'sub', 'f1.out')
 work2_sub_f2_out = test.workpath('work2', 'sub', 'f2.out')
 
 test.write(['work2', 'SConstruct'], """\
-cat_command = r"%(python)s %(cat_py)s ${TARGET.file} ${SOURCE.file}"
+cat_command = r'%(_python_)s %(cat_py)s ${TARGET.file} ${SOURCE.file}'
 env = Environment()
 env.Command('sub/f1.out', 'sub/f1.in', cat_command,
             chdir=1)
 env.Command('sub/f2.out', 'sub/f2.in',
             [
-              r"%(python)s %(cat_py)s .temp ${SOURCE.file}",
-              r"%(python)s %(cat_py)s ${TARGET.file} .temp",
+              r'%(_python_)s %(cat_py)s .temp ${SOURCE.file}',
+              r'%(_python_)s %(cat_py)s ${TARGET.file} .temp',
             ],
             chdir=1)
 """ % locals())
@@ -245,12 +246,14 @@ test.write(['work2', 'sub', 'f2.in'], "work2/sub/f2.in")
 
 expect = test.wrap_stdout("""\
 os.chdir('sub')
-%(python)s %(cat_py)s f1.out f1.in
-os.chdir('%(work2)s')
+%(_python_)s %(cat_py)s f1.out f1.in
+os.chdir(%(work2)s)
 os.chdir('sub')
-%(python)s %(cat_py)s .temp f2.in
-%(python)s %(cat_py)s f2.out .temp
-os.chdir('%(work2)s')
+%(_python_)s %(cat_py)s .temp f2.in
+os.chdir(%(work2)s)
+os.chdir('sub')
+%(_python_)s %(cat_py)s f2.out .temp
+os.chdir(%(work2)s)
 """ % locals())
 
 test.run(chdir='work2', arguments='-n .', stdout=expect)
@@ -274,3 +277,9 @@ test.must_match(work2_sub_f1_out, "work2/sub/f1.in")
 test.must_match(work2_sub_f2_out, "work2/sub/f2.in")
 
 test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: