summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Node/FS.py8
-rw-r--r--src/engine/SCons/Node/FSTests.py12
2 files changed, 19 insertions, 1 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index eb23cd8..ece238a 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -60,6 +60,12 @@ import SCons.Warnings
# there should be *no* changes to the external file system(s)...
#
+if hasattr(os, 'symlink'):
+ def _existsp(p):
+ return os.path.exists(p) or os.path.islink(p)
+else:
+ _existsp = os.path.exists
+
def LinkFunc(target, source, env):
src = source[0].path
dest = target[0].path
@@ -940,7 +946,7 @@ class File(Entry):
def remove(self):
"""Remove this file."""
- if os.path.exists(self.path):
+ if _existsp(self.path):
os.unlink(self.path)
return 1
return None
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index b3fac3f..6ca8182 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -923,6 +923,18 @@ class FSTestCase(unittest.TestCase):
f = fs.File('exists')
r = f.remove()
assert r, r
+ assert not os.path.exists(test.workpath('exists')), "exists was not removed"
+
+ symlink = test.workpath('symlink')
+ try:
+ os.symlink(test.workpath('does_not_exist'), symlink)
+ assert os.path.islink(symlink)
+ f = fs.File('symlink')
+ r = f.remove()
+ assert r, r
+ assert not os.path.islink(symlink), "symlink was not removed"
+ except AttributeError:
+ pass
test.write('can_not_remove', "can_not_remove\n")
test.writable(test.workpath('.'), 0)