Bug 1216371 - Don't rely on OmniJarFormatter.is_resource for test_omnijar_is_resource. r=gps

This commit is contained in:
Mike Hommey 2015-11-11 16:16:15 +09:00
Родитель c8c4eba72c
Коммит 6e8d11c99c
1 изменённых файлов: 44 добавлений и 35 удалений

Просмотреть файл

@ -349,48 +349,57 @@ class TestFormatters(unittest.TestCase):
self.assertEqual(get_contents(registry), RESULT_OMNIJAR_WITH_BASE)
def test_omnijar_is_resource(self):
registry = FileRegistry()
f = OmniJarFormatter(registry, 'omni.foo', non_resources=[
'defaults/messenger/mailViews.dat',
'defaults/foo/*',
'*/dummy',
])
f.add_base('app')
def is_resource(base, path):
registry = FileRegistry()
f = OmniJarFormatter(registry, 'omni.foo', non_resources=[
'defaults/messenger/mailViews.dat',
'defaults/foo/*',
'*/dummy',
])
f.add_base('app')
f.add(mozpath.join(base, path), GeneratedFile(''))
if f.copier.contains(mozpath.join(base, path)):
return False
self.assertTrue(f.copier.contains(mozpath.join(base, 'omni.foo')))
self.assertTrue(f.copier[mozpath.join(base, 'omni.foo')]
.contains(path))
return True
for base in ['', 'app/']:
self.assertTrue(f.is_resource(base + 'chrome'))
self.assertTrue(is_resource(base, 'chrome'))
self.assertTrue(
f.is_resource(base + 'chrome/foo/bar/baz.properties'))
self.assertFalse(f.is_resource(base + 'chrome/icons/foo.png'))
self.assertTrue(f.is_resource(base + 'components/foo.js'))
self.assertFalse(f.is_resource(base + 'components/foo.so'))
self.assertTrue(f.is_resource(base + 'res/foo.css'))
self.assertFalse(f.is_resource(base + 'res/cursors/foo.png'))
self.assertFalse(f.is_resource(base + 'res/MainMenu.nib/'))
self.assertTrue(f.is_resource(base + 'defaults/pref/foo.js'))
is_resource(base, 'chrome/foo/bar/baz.properties'))
self.assertFalse(is_resource(base, 'chrome/icons/foo.png'))
self.assertTrue(is_resource(base, 'components/foo.js'))
self.assertFalse(is_resource(base, 'components/foo.so'))
self.assertTrue(is_resource(base, 'res/foo.css'))
self.assertFalse(is_resource(base, 'res/cursors/foo.png'))
self.assertFalse(is_resource(base, 'res/MainMenu.nib/foo'))
self.assertTrue(is_resource(base, 'defaults/pref/foo.js'))
self.assertFalse(
f.is_resource(base + 'defaults/pref/channel-prefs.js'))
is_resource(base, 'defaults/pref/channel-prefs.js'))
self.assertTrue(
f.is_resource(base + 'defaults/preferences/foo.js'))
is_resource(base, 'defaults/preferences/foo.js'))
self.assertFalse(
f.is_resource(base + 'defaults/preferences/channel-prefs.js'))
self.assertTrue(f.is_resource(base + 'modules/foo.jsm'))
self.assertTrue(f.is_resource(base + 'greprefs.js'))
self.assertTrue(f.is_resource(base + 'hyphenation/foo'))
self.assertTrue(f.is_resource(base + 'update.locale'))
is_resource(base, 'defaults/preferences/channel-prefs.js'))
self.assertTrue(is_resource(base, 'modules/foo.jsm'))
self.assertTrue(is_resource(base, 'greprefs.js'))
self.assertTrue(is_resource(base, 'hyphenation/foo'))
self.assertTrue(is_resource(base, 'update.locale'))
self.assertTrue(
f.is_resource(base + 'jsloader/resource/gre/modules/foo.jsm'))
self.assertFalse(f.is_resource(base + 'foo'))
self.assertFalse(f.is_resource('foo/bar/greprefs.js'))
self.assertTrue(f.is_resource(base + 'defaults/messenger/foo.dat'))
is_resource(base, 'jsloader/resource/gre/modules/foo.jsm'))
self.assertFalse(is_resource(base, 'foo'))
self.assertFalse(is_resource(base, 'foo/bar/greprefs.js'))
self.assertTrue(is_resource(base, 'defaults/messenger/foo.dat'))
self.assertFalse(
f.is_resource(base + 'defaults/messenger/mailViews.dat'))
self.assertTrue(f.is_resource(base + 'defaults/pref/foo.js'))
self.assertFalse(f.is_resource(base + 'defaults/foo/bar.dat'))
self.assertFalse(f.is_resource(base + 'defaults/foo/bar/baz.dat'))
self.assertTrue(f.is_resource(base + 'chrome/foo/bar/baz/dummy_'))
self.assertFalse(f.is_resource(base + 'chrome/foo/bar/baz/dummy'))
self.assertTrue(f.is_resource(base + 'chrome/foo/bar/dummy_'))
self.assertFalse(f.is_resource(base + 'chrome/foo/bar/dummy'))
is_resource(base, 'defaults/messenger/mailViews.dat'))
self.assertTrue(is_resource(base, 'defaults/pref/foo.js'))
self.assertFalse(is_resource(base, 'defaults/foo/bar.dat'))
self.assertFalse(is_resource(base, 'defaults/foo/bar/baz.dat'))
self.assertTrue(is_resource(base, 'chrome/foo/bar/baz/dummy_'))
self.assertFalse(is_resource(base, 'chrome/foo/bar/baz/dummy'))
self.assertTrue(is_resource(base, 'chrome/foo/bar/dummy_'))
self.assertFalse(is_resource(base, 'chrome/foo/bar/dummy'))
if __name__ == '__main__':