Make File() and Dir() take a string for the second argument. (Anthony Roach)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 22 Nov 2002 23:16:35 +0000 (23:16 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 22 Nov 2002 23:16:35 +0000 (23:16 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@501 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py

index 4f071a27c33e21954f64b2cef2b729310cc02cef..077f60b37e7d8cb273e6773ece80e953dbba305a 100644 (file)
@@ -115,6 +115,9 @@ RELEASE 0.09 -
 
   - Make -U and Default('source') fail gracefully.
 
+  - Allow the File() and Dir() methods to take a path-name string as
+    the starting directory, in addition to a Dir object.
+
   From sam th:
 
   - Dynamically check for the existence of utilities with which to
index 3e50d103e994a3fb62ce4fe15f58e22ccda8506d..d66b77710c3b5302175f716f85d455415c73d18c 100644 (file)
@@ -395,6 +395,8 @@ class FS:
         if isinstance(name, Entry):
             return self.__checkClass(name, klass)
         else:
+            if directory and not isinstance(directory, Dir):
+                directory = self.Dir(directory)
             name, directory = self.__transformPath(name, directory)
             return self.__doLookup(klass, name, directory, create)
     
index 9e6e095c97979af0980b605ad8b9b268dcd4e82c..c817408e17af77397c089d7a552e584c2a9f3c90 100644 (file)
@@ -907,7 +907,22 @@ class find_fileTestCase(unittest.TestCase):
         assert os.path.normpath('./foo') in file_names, file_names
         assert os.path.normpath('./bar/baz') in file_names, file_names
 
+class StringDirTestCase(unittest.TestCase):
+    def runTest(self):
+        """Test using a string as the second argument of
+        File() and Dir()"""
 
+        test = TestCmd(workdir = '')
+        test.subdir('sub')
+        fs = SCons.Node.FS.FS(test.workpath(''))
+
+        d = fs.Dir('sub', '.')
+        assert str(d) == 'sub'
+        assert d.exists()
+        f = fs.File('file', 'sub')
+        assert str(f) == os.path.join('sub', 'file')
+        assert not f.exists()
+        
 
 if __name__ == "__main__":
     suite = unittest.TestSuite()
@@ -915,5 +930,6 @@ if __name__ == "__main__":
     suite.addTest(BuildDirTestCase())
     suite.addTest(RepositoryTestCase())
     suite.addTest(find_fileTestCase())
+    suite.addTest(StringDirTestCase())
     if not unittest.TextTestRunner().run(suite).wasSuccessful():
         sys.exit(1)