Fix issue #2419 by sorting the other return path from glob() in FS.py. Thanks to...
authorgaryo <garyo@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 29 May 2009 01:41:22 +0000 (01:41 +0000)
committergaryo <garyo@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 29 May 2009 01:41:22 +0000 (01:41 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@4213 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py

index c34cfed7c8691046f2fffcb3c1acc88958fb31ce..9fdac794fb066ec2145a56c76301ddbe03317f5b 100644 (file)
@@ -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:
index cb2bd68a3d341538cb144e4eb17bdc6150edb10b..9582a9775eb3c46365890620504d8185f9ea61a3 100644 (file)
@@ -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):