Bug 1311871 - Fix NSIS version check for NSIS version 3.0. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 21 Oct 2016 09:15:34 +0900
changeset 427847 9bacde42b376b0c45a4b8210739a270e63fbc405
parent 427846 ec3f77fc67f93b1840ee985ba38b19ea40f9cca9
child 534574 9b8a13ab55214a1a526334f020b3f03736c92f1b
push id33141
push userbmo:mh+mozilla@glandium.org
push dateFri, 21 Oct 2016 00:18:39 +0000
reviewerschmanchester
bugs1311871
milestone52.0a1
Bug 1311871 - Fix NSIS version check for NSIS version 3.0. r?chmanchester
moz.configure
python/mozbuild/mozbuild/test/configure/test_moz_configure.py
--- a/moz.configure
+++ b/moz.configure
@@ -311,17 +311,19 @@ def nsis_version(nsis):
     out = check_cmd_output(nsis, '-version',
                            onerror=lambda: die('Failed to get nsis version.'))
     m = re.search(r'(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?', out)
 
     if not m:
         raise FatalCheckError('Unknown version of makensis')
     ver = Version(m.group(0))
 
-    if ver < nsis_min_version:
+    # Versions comparisons don't quite work well with beta versions, so ensure
+    # it works for the non-beta version.
+    if ver < nsis_min_version and (ver >= '3.0a' or ver < '3'):
         raise FatalCheckError('To build the installer you must have NSIS'
                               ' version %s or greater in your path'
                               % nsis_min_version)
 
     return ver
 
 # And that makensis is 32-bit.
 @depends_if(nsis)
--- a/python/mozbuild/mozbuild/test/configure/test_moz_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_moz_configure.py
@@ -52,11 +52,42 @@ class TestMozConfigure(BaseConfigureTest
         self.assertEquals('--enable-application=browser --with-foo',
                           get_value_for(['--enable-application=browser',
                                          '--with-foo']))
 
         self.assertEquals("--enable-application=browser '--with-foo=foo bar'",
                           get_value_for(['--enable-application=browser',
                                          '--with-foo=foo bar']))
 
+    def test_nsis_version(self):
+        this = self
+
+        class FakeNSIS(object):
+            def __init__(self, version):
+                self.version = version
+
+            def __call__(self, stdin, args):
+                this.assertEquals(args, ('-version',))
+                return 0, self.version, ''
+
+        def check_nsis_version(version):
+            sandbox = self.get_sandbox(
+                {'/usr/bin/makensis': FakeNSIS(version)}, {}, [],
+                {'PATH': '/usr/bin', 'MAKENSISU': '/usr/bin/makensis'})
+            return sandbox._value_for(sandbox['nsis_version'])
+
+        with self.assertRaises(SystemExit) as e:
+            check_nsis_version('v2.5')
+
+        with self.assertRaises(SystemExit) as e:
+            check_nsis_version('v3.0a2')
+
+        self.assertEquals(check_nsis_version('v3.0b1'), '3.0b1')
+        self.assertEquals(check_nsis_version('v3.0b2'), '3.0b2')
+        self.assertEquals(check_nsis_version('v3.0rc1'), '3.0rc1')
+        self.assertEquals(check_nsis_version('v3.0'), '3.0')
+        self.assertEquals(check_nsis_version('v3.0-2'), '3.0')
+        self.assertEquals(check_nsis_version('v3.0.1'), '3.0')
+        self.assertEquals(check_nsis_version('v3.1'), '3.1')
+
 
 if __name__ == '__main__':
     main()