- cleanup = metadata._clean_up_extract_path
- WVPASSEQ(cleanup('/foo'), 'foo')
- WVPASSEQ(cleanup('///foo'), 'foo')
- WVFAIL(cleanup('/../foo'))
- WVFAIL(cleanup('../foo'))
- WVFAIL(cleanup('foo/..'))
- WVFAIL(cleanup('foo/../'))
- WVFAIL(cleanup('foo/../bar'))
- WVPASSEQ(cleanup('foo'), 'foo')
- WVPASSEQ(cleanup('foo/'), 'foo/')
- WVPASSEQ(cleanup('foo///'), 'foo///')
- WVPASSEQ(cleanup('./foo'), './foo')
- WVPASSEQ(cleanup('foo/.'), 'foo/.')
- WVPASSEQ(cleanup('./foo/.'), './foo/.')
- WVPASSEQ(cleanup('foo/bar'), 'foo/bar')
- WVPASSEQ(cleanup('foo/./bar'), 'foo/./bar')
- WVPASSEQ(cleanup('/'), '.')
- WVPASSEQ(cleanup('./'), './')
- WVPASSEQ(cleanup('///foo/bar'), 'foo/bar')
- WVPASSEQ(cleanup('///foo/bar'), 'foo/bar')
+ with no_lingering_errors():
+ cleanup = metadata._clean_up_extract_path
+ WVPASSEQ(cleanup('/foo'), 'foo')
+ WVPASSEQ(cleanup('///foo'), 'foo')
+ WVFAIL(cleanup('/../foo'))
+ WVFAIL(cleanup('../foo'))
+ WVFAIL(cleanup('foo/..'))
+ WVFAIL(cleanup('foo/../'))
+ WVFAIL(cleanup('foo/../bar'))
+ WVPASSEQ(cleanup('foo'), 'foo')
+ WVPASSEQ(cleanup('foo/'), 'foo/')
+ WVPASSEQ(cleanup('foo///'), 'foo///')
+ WVPASSEQ(cleanup('./foo'), './foo')
+ WVPASSEQ(cleanup('foo/.'), 'foo/.')
+ WVPASSEQ(cleanup('./foo/.'), './foo/.')
+ WVPASSEQ(cleanup('foo/bar'), 'foo/bar')
+ WVPASSEQ(cleanup('foo/./bar'), 'foo/./bar')
+ WVPASSEQ(cleanup('/'), '.')
+ WVPASSEQ(cleanup('./'), './')
+ WVPASSEQ(cleanup('///foo/bar'), 'foo/bar')
+ WVPASSEQ(cleanup('///foo/bar'), 'foo/bar')
+
+
+@wvtest
+def test_metadata_method():
+ with no_lingering_errors():
+ with test_tempdir('bup-tmetadata-') as tmpdir:
+ bup_dir = tmpdir + '/bup'
+ data_path = tmpdir + '/foo'
+ os.mkdir(data_path)
+ ex('touch', data_path + '/file')
+ ex('ln', '-s', 'file', data_path + '/symlink')
+ test_time1 = 13 * 1000000000
+ test_time2 = 42 * 1000000000
+ utime(data_path + '/file', (0, test_time1))
+ lutime(data_path + '/symlink', (0, 0))
+ utime(data_path, (0, test_time2))
+ ex(bup_path, '-d', bup_dir, 'init')
+ ex(bup_path, '-d', bup_dir, 'index', '-v', data_path)
+ ex(bup_path, '-d', bup_dir, 'save', '-tvvn', 'test', data_path)
+ git.check_repo_or_die(bup_dir)
+ repo = LocalRepo()
+ resolved = vfs.lresolve(repo,
+ '/test/latest' + resolve_parent(data_path))
+ leaf_name, leaf_item = resolved[-1]
+ m = leaf_item.meta
+ WVPASS(m.mtime == test_time2)
+ WVPASS(leaf_name == 'foo')
+ contents = tuple(vfs.contents(repo, leaf_item))
+ WVPASS(len(contents) == 3)
+ WVPASSEQ(frozenset(name for name, item in contents),
+ frozenset(('.', 'file', 'symlink')))
+ for name, item in contents:
+ if name == 'file':
+ m = item.meta
+ WVPASS(m.mtime == test_time1)
+ elif name == 'symlink':
+ m = item.meta
+ WVPASSEQ(m.symlink_target, 'file')
+ WVPASSEQ(m.size, 4)
+ WVPASSEQ(m.mtime, 0)