summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Node/FSTests.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Node/FSTests.py')
-rw-r--r--src/engine/SCons/Node/FSTests.py88
1 files changed, 77 insertions, 11 deletions
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 044f83f..8b1ee5a 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -84,36 +84,60 @@ class FSTestCase(unittest.TestCase):
for sep in seps:
- def Dir_test(lpath, path, abspath, up_path, fileSys=fs, s=sep):
+ def Dir_test(lpath, path_, abspath_, up_path_, fileSys=fs, s=sep):
dir = fileSys.Dir(string.replace(lpath, '/', s))
+ def strip_slash(p):
+ if p[-1] == '/' and len(p) > 1:
+ p = p[:-1]
+ return p
+ path = strip_slash(path_)
+ abspath = strip_slash(abspath_)
+ up_path = strip_slash(up_path_)
+ name = string.split(abspath, '/')[-1]
+
if os.sep != '/':
path = string.replace(path, '/', os.sep)
+ path_ = string.replace(path_, '/', os.sep)
abspath = string.replace(abspath, '/', os.sep)
+ abspath_ = string.replace(abspath_, '/', os.sep)
up_path = string.replace(up_path, '/', os.sep)
+ up_path_ = string.replace(up_path_, '/', os.sep)
+ assert dir.name == name, \
+ "dir.name %s != expected name %s" % \
+ (dir.name, name)
assert dir.path == path, \
"dir.path %s != expected path %s" % \
(dir.path, path)
assert str(dir) == path, \
"str(dir) %s != expected path %s" % \
(str(dir), path)
+ assert dir.path_ == path_, \
+ "dir.path_ %s != expected path_ %s" % \
+ (dir.path_, path_)
assert dir.abspath == abspath, \
"dir.abspath %s != expected absolute path %s" % \
(dir.abspath, abspath)
+ assert dir.abspath_ == abspath_, \
+ "dir.abspath_ %s != expected absolute path_ %s" % \
+ (dir.abspath_, abspath_)
assert dir.up().path == up_path, \
"dir.up().path %s != expected parent path %s" % \
(dir.up().path, up_path)
+ assert dir.up().path_ == up_path_, \
+ "dir.up().path_ %s != expected parent path_ %s" % \
+ (dir.up().path_, up_path_)
- Dir_test('foo', 'foo/', sub_dir_foo, '.')
+ Dir_test('foo', 'foo/', sub_dir_foo, './')
Dir_test('foo/bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
Dir_test('/foo', '/foo/', '/foo/', '/')
Dir_test('/foo/bar', '/foo/bar/', '/foo/bar/', '/foo/')
Dir_test('..', sub, sub, wp)
- Dir_test('foo/..', '.', sub_dir, sub)
+ Dir_test('foo/..', './', sub_dir, sub)
Dir_test('../foo', sub_foo, sub_foo, sub)
- Dir_test('.', '.', sub_dir, sub)
- Dir_test('./.', '.', sub_dir, sub)
+ Dir_test('.', './', sub_dir, sub)
+ Dir_test('./.', './', sub_dir, sub)
Dir_test('foo/./bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
try:
@@ -136,7 +160,7 @@ class FSTestCase(unittest.TestCase):
f2 = fs.File('d1')
except TypeError, x:
assert str(x) == ("Tried to lookup Dir '%s' as a File." %
- os.path.join('d1', '')), x
+ 'd1'), x
except:
raise
@@ -150,10 +174,16 @@ class FSTestCase(unittest.TestCase):
fs.Dir(string.join(['ddd', 'd1', 'f5'], sep))
kids = map(lambda x: x.path, dir.children())
kids.sort()
- assert kids == [os.path.join('ddd', 'd1', ''),
+ assert kids == [os.path.join('ddd', 'd1'),
os.path.join('ddd', 'f1'),
os.path.join('ddd', 'f2'),
os.path.join('ddd', 'f3')]
+ kids = map(lambda x: x.path_, dir.children())
+ kids.sort()
+ assert kids == [os.path.join('ddd', 'd1', ''),
+ os.path.join('ddd', 'f1'),
+ os.path.join('ddd', 'f2'),
+ os.path.join('ddd', 'f3')]
# Test for sub-classing of node building.
global built_it
@@ -164,7 +194,7 @@ class FSTestCase(unittest.TestCase):
d1.builder_set(Builder())
d1.env_set(Environment())
d1.build()
- assert built_it
+ assert not built_it
assert d1.get_parents() == []
@@ -178,35 +208,71 @@ class FSTestCase(unittest.TestCase):
e1 = fs.Entry("d1")
assert e1.__class__.__name__ == 'Dir'
- assert e1.path == "d1/", e1.path
+ assert e1.path == "d1", e1.path
+ assert e1.path_ == "d1/", e1.path_
+ assert e1.dir.path == ".", e1.dir.path
e2 = fs.Entry("d1/f1")
assert e2.__class__.__name__ == 'File'
assert e2.path == "d1/f1", e2.path
+ assert e2.path_ == "d1/f1", e2.path_
+ assert e2.dir.path == "d1", e2.dir.path
e3 = fs.Entry("e3")
assert e3.__class__.__name__ == 'Entry'
assert e3.path == "e3", e3.path
+ assert e3.path_ == "e3", e3.path_
+ assert e3.dir.path == ".", e3.dir.path
e4 = fs.Entry("d1/e4")
assert e4.__class__.__name__ == 'Entry'
assert e4.path == "d1/e4", e4.path
+ assert e4.path_ == "d1/e4", e4.path_
+ assert e4.dir.path == "d1", e4.dir.path
e5 = fs.Entry("e3/e5")
assert e3.__class__.__name__ == 'Dir'
- assert e3.path == "e3/", e3.path
+ assert e3.path == "e3", e3.path
+ assert e3.path_ == "e3/", e3.path_
+ assert e3.dir.path == ".", e3.dir.path
assert e5.__class__.__name__ == 'Entry'
assert e5.path == "e3/e5", e5.path
+ assert e5.path_ == "e3/e5", e5.path_
+ assert e5.dir.path == "e3", e5.dir.path
e6 = fs.Dir("d1/e4")
assert e6 is e4
assert e4.__class__.__name__ == 'Dir'
- assert e4.path == "d1/e4/", e4.path
+ assert e4.path == "d1/e4", e4.path
+ assert e4.path_ == "d1/e4/", e4.path_
+ assert e4.dir.path == "d1", e4.dir.path
e7 = fs.File("e3/e5")
assert e7 is e5
assert e5.__class__.__name__ == 'File'
assert e5.path == "e3/e5", e5.path
+ assert e5.path_ == "e3/e5", e5.path_
+ assert e5.dir.path == "e3", e5.dir.path
+
+ #XXX test set_signature()
+
+ #XXX test exists()
+
+ #XXX test current() for directories
+
+ #XXX test sconsign() for directories
+
+ #XXX test set_signature() for directories
+
+ #XXX test build() for directories
+
+ #XXX test root()
+
+ #XXX test get_contents()
+
+ #XXX test get_timestamp()
+
+ #XXX test get_oldentry()