summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-11-22 23:16:35 (GMT)
committerSteven Knight <knight@baldmt.com>2002-11-22 23:16:35 (GMT)
commit0984a0820f62db821567e73f73733729b9e193b6 (patch)
tree106659cb203ff4e883234ad8ef9aebebe9c79f81 /src
parentc7ac33dc426b2bab7636bbade3c6dbc726eb3a71 (diff)
downloadSCons-0984a0820f62db821567e73f73733729b9e193b6.zip
SCons-0984a0820f62db821567e73f73733729b9e193b6.tar.gz
SCons-0984a0820f62db821567e73f73733729b9e193b6.tar.bz2
Make File() and Dir() take a string for the second argument. (Anthony Roach)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Node/FS.py2
-rw-r--r--src/engine/SCons/Node/FSTests.py16
3 files changed, 21 insertions, 0 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 4f071a2..077f60b 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -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
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 3e50d10..d66b777 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -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)
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 9e6e095..c817408 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -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)