Bug 1441484 - fix error handling in make_incremental_updates. r=bhearsum draft
authorJulien Cristau <jcristau@mozilla.com>
Tue, 27 Feb 2018 10:36:15 +0100
changeset 760377 60963d642b37a127510e6d9dfad5bd556fc5d3b0
parent 760371 b184be59874080e96903183176c0f88dcbfafe25
push id100619
push userjcristau@mozilla.com
push dateTue, 27 Feb 2018 13:55:18 +0000
reviewersbhearsum
bugs1441484
milestone60.0a1
Bug 1441484 - fix error handling in make_incremental_updates. r=bhearsum MozReview-Commit-ID: 4jpZqMW0yYX
tools/update-packaging/make_incremental_updates.py
tools/update-packaging/test_make_incremental_updates.py
--- 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()