summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-11-30 05:30:47 (GMT)
committerSteven Knight <knight@baldmt.com>2002-11-30 05:30:47 (GMT)
commit454239b699f5b3b81ef3b10aa3e97361eadbf5f4 (patch)
treef7bba81881c008f2968f589842544d2a68854d01 /src
parent4e5b73e5e77664749549fc5082550f82c4064604 (diff)
downloadSCons-454239b699f5b3b81ef3b10aa3e97361eadbf5f4.zip
SCons-454239b699f5b3b81ef3b10aa3e97361eadbf5f4.tar.gz
SCons-454239b699f5b3b81ef3b10aa3e97361eadbf5f4.tar.bz2
Really take care of non-existent drive letters on Win32.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Node/FS.py15
-rw-r--r--src/engine/SCons/Node/FSTests.py31
2 files changed, 37 insertions, 9 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index d5247f7..b805d4a 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -820,7 +820,7 @@ class File(Entry):
def scanner_key(self):
return os.path.splitext(self.name)[1]
- def __createDir(self):
+ def _createDir(self):
# ensure that the directories for this node are
# created.
@@ -830,7 +830,10 @@ class File(Entry):
if parent.exists():
break
listDirs.append(parent)
- parent = parent.up()
+ p = parent.up()
+ if isinstance(p, ParentOfRoot):
+ raise SCons.Errors.StopError, parent.path
+ parent = p
listDirs.reverse()
for dirnode in listDirs:
try:
@@ -862,7 +865,11 @@ class File(Entry):
if hasattr(self, '_exists'):
delattr(self, '_exists')
else:
- self.__createDir()
+ try:
+ self._createDir()
+ except SCons.Errors.StopError, drive:
+ desc = "No drive `%s' for target `%s'." % (drive, self)
+ raise SCons.Errors.StopError, desc
def remove(self):
"""Remove this file."""
@@ -880,7 +887,7 @@ class File(Entry):
os.unlink(self.abspath)
except OSError:
pass
- self.__createDir()
+ self._createDir()
file_link(src.abspath, self.abspath)
self.created = 1
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 5d32873..8386f83 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -31,7 +31,7 @@ import time
import unittest
import SCons.Node.FS
from TestCmd import TestCmd
-from SCons.Errors import UserError
+import SCons.Errors
import stat
built_it = None
@@ -255,7 +255,7 @@ class BuildDirTestCase(unittest.TestCase):
try:
fs = SCons.Node.FS.FS()
fs.BuildDir('build', '/test/foo')
- except UserError:
+ except SCons.Errors.UserError:
exc_caught = 1
assert exc_caught, "Should have caught a UserError."
@@ -263,7 +263,7 @@ class BuildDirTestCase(unittest.TestCase):
try:
fs = SCons.Node.FS.FS()
fs.BuildDir('build', 'build/src')
- except UserError:
+ except SCons.Errors.UserError:
exc_caught = 1
assert exc_caught, "Should have caught a UserError."
@@ -604,7 +604,7 @@ class FSTestCase(unittest.TestCase):
def nonexistent(method, s):
try:
x = method(s, create = 0)
- except UserError:
+ except SCons.Errors.UserError:
pass
else:
raise TestFailed, "did not catch expected UserError"
@@ -923,7 +923,27 @@ class StringDirTestCase(unittest.TestCase):
f = fs.File('file', 'sub')
assert str(f) == os.path.join('sub', 'file')
assert not f.exists()
-
+
+class prepareTestCase(unittest.TestCase):
+ def runTest(self):
+ """Test the prepare() method"""
+
+ class MyFile(SCons.Node.FS.File):
+ def _createDir(self):
+ raise SCons.Errors.StopError
+ def exists(self):
+ return None
+
+ fs = SCons.Node.FS.FS()
+ file = MyFile('foo', fs.Dir('.'), fs)
+
+ exc_caught = 0
+ try:
+ file.prepare()
+ except SCons.Errors.StopError:
+ exc_caught = 1
+ assert exc_caught, "Should have caught a StopError."
+
if __name__ == "__main__":
suite = unittest.TestSuite()
@@ -932,5 +952,6 @@ if __name__ == "__main__":
suite.addTest(RepositoryTestCase())
suite.addTest(find_fileTestCase())
suite.addTest(StringDirTestCase())
+ suite.addTest(prepareTestCase())
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)