Bug 1441484 - fix error handling in make_incremental_updates. r=bhearsum
MozReview-Commit-ID: 4jpZqMW0yYX
--- a/tools/update-packaging/make_incremental_updates.py
+++ b/tools/update-packaging/make_incremental_updates.py
@@ -455,17 +455,17 @@ def decode_filename(filepath):
Or linux-i686/en-US/firefox-3.0b3.complete.mar
Returns dict with keys product, version, locale, platform, type
"""
try:
m = re.search(
'(?P<product>\w+)(-)(?P<version>\w+\.\w+(\.\w+){0,2})(\.)(?P<locale>.+?)(\.)(?P<platform>.+?)(\.)(?P<type>\w+)(.mar)',
os.path.basename(filepath))
return m.groupdict()
- except Exception(exc):
+ except Exception as exc:
try:
m = re.search(
'(?P<platform>.+?)\/(?P<locale>.+?)\/(?P<product>\w+)-(?P<version>\w+\.\w+)\.(?P<type>\w+).mar',
filepath)
return m.groupdict()
except:
raise Exception("could not parse filepath %s: %s" % (filepath, exc))
--- a/tools/update-packaging/test_make_incremental_updates.py
+++ b/tools/update-packaging/test_make_incremental_updates.py
@@ -140,12 +140,15 @@ class TestMakeIncrementalUpdates(unittes
""" FIXME touches the filesystem, need refactoring
def test_get_buildid(self):
mkup.get_buildid('work_dir', 'platform')
"""
def test_decode_filename(self):
expected = {'locale': 'lang', 'platform': 'platform', 'product': 'product', 'version': '1.0', 'type': 'complete'}
self.assertEquals(expected, mkup.decode_filename('product-1.0.lang.platform.complete.mar'))
- self.assertRaises(Exception, mkup.decode_filename, 'fail')
+ self.assertEquals(expected, mkup.decode_filename('platform/lang/product-1.0.complete.mar'))
+ with self.assertRaises(Exception) as cm:
+ mkup.decode_filename('fail')
+ self.assertTrue(cm.exception.args[0].startswith('could not parse filepath fail:'))
if __name__ == '__main__':
unittest.main()