Fix a regression in handling CPPPATH='.' when using a BuildDir with subdirectories...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Mar 2005 15:25:36 +0000 (15:25 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Mar 2005 15:25:36 +0000 (15:25 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1244 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py
test/BuildDir/BuildDir.py [moved from test/BuildDir.py with 100% similarity]
test/BuildDir/CPPPATH-subdir.py [new file with mode: 0644]
test/BuildDir/Sconscript-build_dir.py [moved from test/SConscript-build_dir.py with 100% similarity]
test/BuildDir/errors.py [moved from test/BuildDir-errors.py with 100% similarity]
test/BuildDir/reflect.py [moved from test/builddir-reflect.py with 100% similarity]

index df974de319a97e1e625c2d10fe4010ce3949f8d8..9dfd355b7eccf07e40624568a010df75ee12d0bb 100644 (file)
@@ -1084,10 +1084,6 @@ class FS(LocalFS):
             else:
                 if not must_exist or node.exists():
                     result.append(node)
-                if isinstance(node, Dir):
-                    result.extend(filter(select, node.getRepositories()))
-                if node:
-                    dir = node.get_dir()
             fname = '.'
             while dir:
                 for rep in dir.getRepositories():
index 5034d167c3e7549fb54b471292e1b5b895844808..1d7d926e50ca0c77ffcbd91b5d76461bca559632 100644 (file)
@@ -1494,57 +1494,87 @@ class EntryTestCase(unittest.TestCase):
 
 
 
-class RepositoryTestCase(unittest.TestCase):
-    def runTest(self):
-        """Test FS (file system) Repository operations
+class RepositoryTestCase(_tempdirTestCase):
 
-        """
-        fs = SCons.Node.FS.FS()
+    def setUp(self):
+        _tempdirTestCase.setUp(self)
 
-        fs.Repository('foo')
-        fs.Repository(os.path.join('foo', 'bar'))
-        fs.Repository(os.path.join('bar', 'foo'))
-        fs.Repository('bar')
+        self.test.subdir('rep1', 'rep2', 'rep3', 'work')
 
-        rep = fs.Dir('#').getRepositories()
-        assert len(rep) == 4, map(str, rep)
-        r = map(lambda x, np=os.path.normpath: np(str(x)), rep)
-        assert r == ['foo',
-                     os.path.join('foo', 'bar'),
-                     os.path.join('bar', 'foo'),
-                     'bar'], r
+        self.rep1 = self.test.workpath('rep1')
+        self.rep2 = self.test.workpath('rep2')
+        self.rep3 = self.test.workpath('rep3')
 
-        test = TestCmd(workdir = '')
-        test.subdir('rep1', 'rep2', 'rep3', 'work')
+        os.chdir(self.test.workpath('work'))
 
-        rep1 = test.workpath('rep1')
-        rep2 = test.workpath('rep2')
-        rep3 = test.workpath('rep3')
+        self.fs = SCons.Node.FS.FS()
+        self.fs.Repository(self.rep1, self.rep2, self.rep3)
+
+    def test_getRepositories(self):
+        """Test the Dir.getRepositories() method"""
+        self.fs.Repository('foo')
+        self.fs.Repository(os.path.join('foo', 'bar'))
+        self.fs.Repository('bar/foo')
+        self.fs.Repository('bar')
+
+        expect = [
+            self.rep1,
+            self.rep2,
+            self.rep3,
+            'foo',
+            os.path.join('foo', 'bar'),
+            os.path.join('bar', 'foo'),
+            'bar'
+        ]
 
-        os.chdir(test.workpath('work'))
+        rep = self.fs.Dir('#').getRepositories()
+        r = map(lambda x, np=os.path.normpath: np(str(x)), rep)
+        assert r == expect, r
 
-        fs = SCons.Node.FS.FS()
-        fs.Repository(rep1, rep2, rep3)
+    def test_rfile(self):
+        """Test the File.rfile() method"""
+        f1 = self.fs.File('f1')
+        f2 = self.fs.File('f2')
+        f3 = self.fs.File('f3')
+
+        self.test.write([self.rep1, 'f2'], "")
+        self.test.subdir([self.rep2, 'f3'])
+        self.test.write([self.rep3, 'f3'], "")
 
-        f1 = fs.File(os.path.join('f1'))
         assert f1.rfile() is f1
 
-        test.write([rep1, 'f2'], "")
+        r = f2.rfile()
+        assert not r is f2, r
+        assert str(r) == os.path.join(self.rep1, 'f2'), str(r)
 
-        f2 = fs.File('f2')
-        assert not f2.rfile() is f2, f2.rfile()
-        assert str(f2.rfile()) == os.path.join(rep1, 'f2'), str(f2.rfile())
+        r = f3.rfile()
+        assert not r is f3, r
+        r = f3.rstr()
+        assert r == os.path.join(self.rep3, 'f3'), r
+
+    def test_Rsearches(self):
+        """Test the Rsearch() methods"""
+        fs = self.fs
+        test = self.test
 
-        test.subdir([rep2, 'f3'])
-        test.write([rep3, 'f3'], "")
+        test.write([self.rep1, 'f2'], "")
+        test.subdir([self.rep2, 'f3'])
+        test.write([self.rep3, 'f3'], "")
+
+        r = fs.Rsearch('f1')
+        assert r is None, r
+
+        r = fs.Rsearch('f2')
+        assert r, r
 
         f3 = fs.File('f3')
-        assert not f3.rfile() is f3, f3.rfile()
-        assert f3.rstr() == os.path.join(rep3, 'f3'), f3.rstr()
+        r = fs.Rsearch(f3)
+        assert r is f3, r
 
-        assert fs.Rsearch('f1') is None
-        assert fs.Rsearch('f2')
-        assert fs.Rsearch(f3) is f3
+    def test_Rsearchall(self):
+        """Test the Rsearchall() methods"""
+        fs = self.fs
+        test = self.test
 
         list = fs.Rsearchall(fs.Dir('d1'))
         assert len(list) == 1, list
@@ -1562,16 +1592,19 @@ class RepositoryTestCase(unittest.TestCase):
 
         fs.File('d2').built() # Clear exists cache
         test.subdir(['work', 'd2'])
+
         list = fs.Rsearchall('d2')
         assert map(str, list) == ['d2'], list
 
         fs.File('../rep2/d2').built() # Clear exists cache
         test.subdir(['rep2', 'd2'])
+
         list = fs.Rsearchall('d2')
         assert map(str, list) == ['d2', test.workpath('rep2', 'd2')], list
 
         fs.File('../rep1/d2').built() # Clear exists cache
         test.subdir(['rep1', 'd2'])
+
         list = fs.Rsearchall('d2')
         assert map(str, list) == ['d2',
                                   test.workpath('rep1', 'd2'),
@@ -1582,11 +1615,13 @@ class RepositoryTestCase(unittest.TestCase):
 
         fs.File('d3').built() # Clear exists cache
         test.subdir(['work', 'd3'])
+
         list = map(str, fs.Rsearchall(['d3', 'd4']))
         assert list == ['d3'], list
 
         fs.File('../rep3/d4').built() # Clear exists cache
         test.subdir(['rep3', 'd4'])
+
         list = map(str, fs.Rsearchall(['d3', 'd4']))
         assert list == ['d3', test.workpath('rep3', 'd4')], list
 
@@ -1594,6 +1629,7 @@ class RepositoryTestCase(unittest.TestCase):
         assert list == ['d3', test.workpath('rep3', 'd4')], list
 
         work_d4 = fs.File(os.path.join('work', 'd4'))
+
         list = map(str, fs.Rsearchall(['d3', work_d4]))
         assert list == ['d3', str(work_d4)], list
 
@@ -1606,12 +1642,19 @@ class RepositoryTestCase(unittest.TestCase):
         list = fs.Rsearchall([''])
         assert list == [], list
 
+    def test_rexists(self):
+        """Test the Entry.rexists() method"""
+        fs = self.fs
+        test = self.test
+
+        test.write([self.rep1, 'f2'], "")
+
         fs.BuildDir('build', '.')
 
         f = fs.File(test.workpath("work", "i_do_not_exist"))
         assert not f.rexists()
 
-        test.write(["rep2", "i_exist"], "\n")
+        test.write([self.rep2, "i_exist"], "\n")
         f = fs.File(test.workpath("work", "i_exist"))
         assert f.rexists()
 
@@ -1625,6 +1668,11 @@ class RepositoryTestCase(unittest.TestCase):
         f2 = fs.File(os.path.join('build', 'f2'))
         assert f2.rexists()
 
+    def test_FAT_timestamps(self):
+        """Test repository timestamps on FAT file systems"""
+        fs = self.fs
+        test = self.test
+
         test.write(["rep2", "tstamp"], "tstamp\n")
         try:
             # Okay, *this* manipulation accomodates Windows FAT file systems
@@ -1640,7 +1688,11 @@ class RepositoryTestCase(unittest.TestCase):
         finally:
             test.unlink(["rep2", "tstamp"])
 
-        # Make sure get_contents() returns the binary contents.
+    def test_get_contents(self):
+        """Ensure get_contents() returns binary contents from Repositories"""
+        fs = self.fs
+        test = self.test
+
         test.write(["rep3", "contents"], "Con\x1aTents\n")
         try:
             c = fs.File("contents").get_contents()
@@ -1648,9 +1700,11 @@ class RepositoryTestCase(unittest.TestCase):
         finally:
             test.unlink(["rep3", "contents"])
 
-        # XXX test calc_signature()
+    #def test calc_signature(self):
+
+    #def test current(self):
+
 
-        # XXX test current()
 
 class find_fileTestCase(unittest.TestCase):
     def runTest(self):
@@ -2372,7 +2426,6 @@ if __name__ == "__main__":
     suite.addTest(FSTestCase())
     suite.addTest(BuildDirTestCase())
     suite.addTest(EntryTestCase())
-    suite.addTest(RepositoryTestCase())
     suite.addTest(find_fileTestCase())
     suite.addTest(StringDirTestCase())
     suite.addTest(stored_infoTestCase())
@@ -2387,6 +2440,7 @@ if __name__ == "__main__":
     suite.addTest(SaveStringsTestCase())
     tclasses = [
         DirTestCase,
+        RepositoryTestCase,
     ]
     for tclass in tclasses:
         names = unittest.getTestCaseNames(tclass, 'test_')
similarity index 100%
rename from test/BuildDir.py
rename to test/BuildDir/BuildDir.py
diff --git a/test/BuildDir/CPPPATH-subdir.py b/test/BuildDir/CPPPATH-subdir.py
new file mode 100644 (file)
index 0000000..2ae50b5
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test handling of the current directory (.) in CPPPATH when
+the include path contains a subdirectory.
+
+This tests for a regression found in 0.96.90 by Chad Austin.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('src', ['src', 'glscry'])
+
+test.write('SConstruct', """\
+env = Environment()
+Export('env')
+SConscript(dirs=['src'], build_dir='build', duplicate=0)
+""")
+
+
+test.write(['src', 'SConscript'], """\
+SConscript(dirs=['glscry'])
+""")
+
+
+test.write(['src', 'glscry', 'SConscript'], """\
+Import('*')
+env = env.Copy()
+env.Append(CPPPATH=['.'])
+env.Library('foo', 'foo.c')
+""")
+
+test.write(['src', 'glscry', 'foo.c'], """\
+#include <foo.h>
+""")
+
+
+test.write(['src', 'glscry', 'foo.h'], "\n")
+
+test.run(arguments = '.',
+         stderr = TestSCons.noisy_ar,
+         match = TestSCons.match_re_dotall)
+
+test.pass_test()