Integrate patch from issue #2436: fix regression from r3691 which stopped printing...
authorgaryo <garyo@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Dec 2009 02:39:27 +0000 (02:39 +0000)
committergaryo <garyo@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Dec 2009 02:39:27 +0000 (02:39 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@4512 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Script/Main.py
test/option--C.py

index dd4f519783dcb1a55f651bbfd55248ddd24704df..082de3415026132b440b8052ee79229db19ad83a 100644 (file)
@@ -806,16 +806,13 @@ def _main(parser):
     # want to start everything, which means first handling any relevant
     # options that might cause us to chdir somewhere (-C, -D, -U, -u).
     if options.directory:
-        cdir = _create_path(options.directory)
-        try:
-            os.chdir(cdir)
-        except OSError:
-            sys.stderr.write("Could not change directory to %s\n" % cdir)
+        script_dir = os.path.abspath(_create_path(options.directory))
+    else:
+        script_dir = os.getcwd()
 
     target_top = None
     if options.climb_up:
         target_top = '.'  # directory to prepend to targets
-        script_dir = os.getcwd()  # location of script
         while script_dir and not _SConstruct_exists(script_dir,
                                                     options.repository,
                                                     options.file):
@@ -824,9 +821,13 @@ def _main(parser):
                 target_top = os.path.join(last_part, target_top)
             else:
                 script_dir = ''
-        if script_dir and script_dir != os.getcwd():
-            display("scons: Entering directory `%s'" % script_dir)
+
+    if script_dir and script_dir != os.getcwd():
+        display("scons: Entering directory `%s'" % script_dir)
+        try:
             os.chdir(script_dir)
+        except OSError:
+            sys.stderr.write("Could not change directory to %s\n" % script_dir)
 
     # Now that we're in the top-level SConstruct directory, go ahead
     # and initialize the FS object that represents the file system,
index fac754864da7dd8ac8c09dbcc9e5d1a2619d5820..3d93d2f7a86ce9387bae1ae40357de77a5153ae8 100644 (file)
@@ -68,24 +68,28 @@ print env.GetBuildPath('../$FOO/$BAR')
 """)
 
 test.run(arguments = '-C sub .',
-         stdout = test.wrap_stdout(read_str = '%s\n' % wpath,
-                                   build_str = "scons: `.' is up to date.\n"))
+         stdout = "scons: Entering directory `%s'\n" % wpath_sub \
+             + test.wrap_stdout(read_str = '%s\n' % wpath,
+                                build_str = "scons: `.' is up to date.\n"))
 
 test.run(arguments = '-C sub -C dir .',
-         stdout = test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
-                                   build_str = "scons: `.' is up to date.\n"))
+         stdout = "scons: Entering directory `%s'\n" % wpath_sub_dir \
+             + test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
+                                build_str = "scons: `.' is up to date.\n"))
 
 test.run(arguments = ".",
          stdout = test.wrap_stdout(read_str = 'SConstruct %s\n' % wpath,
                                    build_str = "scons: `.' is up to date.\n"))
 
 test.run(arguments = '--directory=sub/dir .',
-         stdout = test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
-                                   build_str = "scons: `.' is up to date.\n"))
+         stdout = "scons: Entering directory `%s'\n" % wpath_sub_dir \
+             + test.wrap_stdout(read_str = '%s\n' % wpath_sub_foo_bar,
+                                build_str = "scons: `.' is up to date.\n"))
 
 test.run(arguments = '-C %s -C %s .' % (wpath_sub_dir, wpath_sub),
-         stdout = test.wrap_stdout(read_str = '%s\n' % wpath,
-                                   build_str = "scons: `.' is up to date.\n"))
+         stdout = "scons: Entering directory `%s'\n" % wpath_sub \
+             + test.wrap_stdout(read_str = '%s\n' % wpath,
+                                build_str = "scons: `.' is up to date.\n"))
 
 test.pass_test()