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