-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
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'),
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
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
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()
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
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()
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):
suite.addTest(FSTestCase())
suite.addTest(BuildDirTestCase())
suite.addTest(EntryTestCase())
- suite.addTest(RepositoryTestCase())
suite.addTest(find_fileTestCase())
suite.addTest(StringDirTestCase())
suite.addTest(stored_infoTestCase())
suite.addTest(SaveStringsTestCase())
tclasses = [
DirTestCase,
+ RepositoryTestCase,
]
for tclass in tclasses:
names = unittest.getTestCaseNames(tclass, 'test_')
--- /dev/null
+#!/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()