From: garyo Date: Fri, 29 May 2009 01:41:22 +0000 (+0000) Subject: Fix issue #2419 by sorting the other return path from glob() in FS.py. Thanks to... X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=05c1938f7864a2e18aca48f30bc210bbf712503f;p=scons.git Fix issue #2419 by sorting the other return path from glob() in FS.py. Thanks to Jin Liu for the original analysis of the problem. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4213 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index c34cfed7..9fdac794 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1953,7 +1953,9 @@ class Dir(Base): """ dirname, basename = os.path.split(pathname) if not dirname: - return self._glob1(basename, ondisk, source, strings) + result = self._glob1(basename, ondisk, source, strings) + result.sort(lambda a, b: cmp(str(a), str(b))) + return result if has_glob_magic(dirname): list = self.glob(dirname, ondisk, source, strings=False) else: diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index cb2bd68a..9582a977 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -2179,8 +2179,8 @@ class GlobTestCase(_tempdirTestCase): # Make entries on disk that will not have Nodes, so we can verify # the behavior of looking for things on disk. - self.test.write('disk-aaa', "disk-aaa\n") self.test.write('disk-bbb', "disk-bbb\n") + self.test.write('disk-aaa', "disk-aaa\n") self.test.write('disk-ccc', "disk-ccc\n") self.test.write('#disk-hash', "#disk-hash\n") self.test.subdir('disk-sub') @@ -2489,6 +2489,8 @@ class GlobTestCase(_tempdirTestCase): join = os.path.join # At least sometimes this should return out-of-order items # if Glob doesn't sort. + # It's not a very good test though since it depends on the + # order returned by glob, which might already be sorted. g = self.fs.Glob('disk-sub/*', strings=True) expect = [ os.path.join('disk-sub', 'disk-ddd'), @@ -2497,6 +2499,10 @@ class GlobTestCase(_tempdirTestCase): ] assert g == expect, str(g) + " is not sorted, but should be!" + g = self.fs.Glob('disk-*', strings=True) + expect = [ 'disk-aaa', 'disk-bbb', 'disk-ccc', 'disk-sub' ] + assert g == expect, str(g) + " is not sorted, but should be!" + class RepositoryTestCase(_tempdirTestCase):