- 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(), 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)
+ top = vfs.RefList(None)
+ n = top.lresolve('/test/latest' + resolve_parent(data_path))
+ m = n.metadata()
+ WVPASS(m.mtime == test_time2)
+ WVPASS(len(n.subs()) == 2)
+ WVPASS(n.name == 'foo')
+ WVPASS(set([x.name for x in n.subs()]) == set(['file', 'symlink']))
+ for sub in n:
+ if sub.name == 'file':
+ m = sub.metadata()
+ WVPASS(m.mtime == test_time1)
+ elif sub.name == 'symlink':
+ m = sub.metadata()
+ WVPASS(m.mtime == 0)