Commits

Anonymous committed bd2841c

Add -C support.

Comments (0)

Files changed (3)

doc/man/options.sgml

         <filename>Sconstruct</filename> or
         <filename>sconstruct</filename> file, or doing anything
         else.  Multiple <option>-C</option> options are interpreted
-        relative to the previous one.  (This is nearly equivalent
-        to <literal>-f directory/SConstruct</literal>, except
-        that it will search for <filename>SConstruct</filename>,
+        relative to the previous one, and the right-most
+        <option>-C</option> option wins.  (This option is nearly
+        equivalent to <literal>-f directory/SConstruct</literal>,
+        except that it will search for <filename>SConstruct</filename>,
         <filename>Sconstruct</filename>, or
-        <filename>sconstruct</filename> in the directory.)
+        <filename>sconstruct</filename> in the specified directory.)
 
       </para>
     </listitem>
 	long = ['cache-show'],
 	help = "Print what would have built Cached targets.")
 
-Option(func = opt_not_yet,
+def opt_C(opt, arg):
+    try:
+	os.chdir(arg)
+    except:
+	sys.stderr.write("Could not change directory to 'arg'\n")
+
+Option(func = opt_C,
 	short = 'C', long = ['directory'], arg = 'DIRECTORY',
 	help = "Change to DIRECTORY before doing anything.")
 

test/option--C.py

                        workdir = '',
                        interpreter = 'python')
 
-test.write('SConstruct', "")
+wpath = test.workpath()
+wpath_sub = test.workpath('sub')
+wpath_sub_dir = test.workpath('sub', 'dir')
 
-test.run(chdir = '.', arguments = '-C foo')
+test.subdir('sub', ['sub', 'dir'])
 
-test.fail_test(test.stderr() !=
-		"Warning:  the -C option is not yet implemented\n")
+test.write('SConstruct', """
+import os
+print "SConstruct", os.getcwd()
+""")
 
-test.run(chdir = '.', arguments = '--directory=foo')
+test.write(['sub', 'SConstruct'], """
+import os
+print "sub/SConstruct", os.getcwd()
+""")
 
-test.fail_test(test.stderr() !=
-		"Warning:  the --directory option is not yet implemented\n")
+test.write(['sub', 'dir', 'SConstruct'], """
+import os
+print "sub/dir/SConstruct", os.getcwd()
+""")
+
+test.run(chdir = '.', arguments = '-C sub')
+
+test.fail_test(test.stdout() != "sub/SConstruct %s\n" % wpath_sub)
+test.fail_test(test.stderr() != "")
+
+test.run(chdir = '.', arguments = '-C sub -C dir')
+
+test.fail_test(test.stdout() != "sub/dir/SConstruct %s\n" % wpath_sub_dir)
+test.fail_test(test.stderr() != "")
+
+test.run(chdir = '.')
+
+test.fail_test(test.stdout() != "SConstruct %s\n" % wpath)
+test.fail_test(test.stderr() != "")
+
+test.run(chdir = '.', arguments = '--directory=sub/dir')
+
+test.fail_test(test.stdout() != "sub/dir/SConstruct %s\n" % wpath_sub_dir)
+test.fail_test(test.stderr() != "")
+
+test.run(chdir = '.', arguments = '-C %s -C %s' % (wpath_sub_dir, wpath_sub))
+
+test.fail_test(test.stdout() != "sub/SConstruct %s\n" % wpath_sub)
+test.fail_test(test.stderr() != "")
 
 test.pass_test()
  
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.