Bug 1311871 - Fix NSIS version check for NSIS version 3.0. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 21 Oct 2016 09:15:34 +0900
changeset 318960 619ccb0d81f1adc30894807a13196d63ddbe7966
parent 318959 a12133c22f121112c72c12dd0866ec4b3aabb31a
child 318961 5639a9f476d08f300c079117e61697f5026b6367
child 318963 d4c055d13bc8bc149b4d7bdaf0e566ca50ba5a47
push id30855
push userryanvm@gmail.com
push dateFri, 21 Oct 2016 21:12:44 +0000
treeherdermozilla-central@5639a9f476d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1311871
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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()