summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-03-01 02:01:53 (GMT)
committerSteven Knight <knight@baldmt.com>2005-03-01 02:01:53 (GMT)
commitc4b35b0ad854432a32fe9d09c2fdd8bdafc40fd8 (patch)
tree1f909659d67d0c8910a1837f3c8323f5686ad6c5 /src
parent69e1562853db2f1836a0942e1cc01aeb87858a9d (diff)
downloadSCons-c4b35b0ad854432a32fe9d09c2fdd8bdafc40fd8.zip
SCons-c4b35b0ad854432a32fe9d09c2fdd8bdafc40fd8.tar.gz
SCons-c4b35b0ad854432a32fe9d09c2fdd8bdafc40fd8.tar.bz2
Don't throw a 'Tried to lookup a File as a Dir' exception if there's a same-named file as a directory we might try to search for an included file.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Node/FS.py9
-rw-r--r--src/engine/SCons/Node/FSTests.py15
2 files changed, 21 insertions, 3 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index e7b283d..e42166f 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1888,7 +1888,14 @@ def find_file(filename, paths, node_factory=default_fs.File, verbose=None):
for pathdir in paths:
verbose("looking for '%s' in '%s' ...\n" % (filename, pathdir))
- dir = lookup_dir(pathdir)
+
+ try: dir = lookup_dir(pathdir)
+ except TypeError: dir = None
+ if not dir:
+ # We tried to look up a directory, but it seems there's
+ # already a file node (or something else) there. No big.
+ continue
+
def func(node):
if isinstance(node, SCons.Node.FS.File) and \
(node.is_derived() or node.is_pseudo_derived() or node.exists()):
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index f123bb9..f841d32 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -1432,23 +1432,34 @@ class find_fileTestCase(unittest.TestCase):
test.subdir('bar')
test.write(['bar', 'on_disk'], 'Another file\n')
test.write(['bar', 'same'], 'bar/same\n')
+
fs = SCons.Node.FS.FS(test.workpath(""))
- os.chdir(test.workpath("")) # FS doesn't like the cwd to be something other than it's root
+ # FS doesn't like the cwd to be something other than its root.
+ os.chdir(test.workpath(""))
+
node_derived = fs.File(test.workpath('bar/baz'))
node_derived.builder_set(1) # Any non-zero value.
node_pseudo = fs.File(test.workpath('pseudo'))
node_pseudo.set_src_builder(1) # Any non-zero value.
+
paths = map(fs.Dir, ['.', 'same', './bar'])
nodes = [SCons.Node.FS.find_file('foo', paths, fs.File)]
nodes.append(SCons.Node.FS.find_file('baz', paths, fs.File))
nodes.append(SCons.Node.FS.find_file('pseudo', paths, fs.File))
- nodes.append(SCons.Node.FS.find_file('same', paths, fs.File, verbose=1))
+ nodes.append(SCons.Node.FS.find_file('same', paths, fs.File))
+
file_names = map(str, nodes)
file_names = map(os.path.normpath, file_names)
expect = ['./foo', './bar/baz', './pseudo', './bar/same']
expect = map(os.path.normpath, expect)
assert file_names == expect, file_names
+ # Make sure we don't blow up if there's already a File in place
+ # of a directory that we'd otherwise try to search. If this
+ # is broken, we'll see an exception like "Tried to lookup File
+ # 'bar/baz' as a Dir.
+ SCons.Node.FS.find_file('baz/no_file_here', paths, fs.File)
+
import StringIO
save_sys_stdout = sys.stdout