diff options
Diffstat (limited to 'python/mozbuild/mozbuild/repackaging/test')
-rw-r--r-- | python/mozbuild/mozbuild/repackaging/test/python.ini | 4 | ||||
-rw-r--r-- | python/mozbuild/mozbuild/repackaging/test/test_msix.py | 53 |
2 files changed, 57 insertions, 0 deletions
diff --git a/python/mozbuild/mozbuild/repackaging/test/python.ini b/python/mozbuild/mozbuild/repackaging/test/python.ini new file mode 100644 index 0000000000..f51fad30a3 --- /dev/null +++ b/python/mozbuild/mozbuild/repackaging/test/python.ini @@ -0,0 +1,4 @@ +[DEFAULT] +subsuite = mozbuild + +[test_msix.py] diff --git a/python/mozbuild/mozbuild/repackaging/test/test_msix.py b/python/mozbuild/mozbuild/repackaging/test/test_msix.py new file mode 100644 index 0000000000..f6735dcc75 --- /dev/null +++ b/python/mozbuild/mozbuild/repackaging/test/test_msix.py @@ -0,0 +1,53 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import unittest + +from mozunit import main + +from mozbuild.repackaging.msix import get_embedded_version + + +class TestMSIX(unittest.TestCase): + def test_embedded_version(self): + """Test embedded version extraction.""" + + buildid = "YYYY0M0D0HMmSs" + for input, output in [ + ("X.0a1", "X.YY0M.D0H.0"), + ("X.YbZ", "X.Y.Z.0"), + ("X.Yesr", "X.Y.0.0"), + ("X.Y.Zesr", "X.Y.Z.0"), + ("X.YrcZ", "X.Y.Z.0"), + ("X.Y", "X.Y.0.0"), + ("X.Y.Z", "X.Y.Z.0"), + ]: + version = get_embedded_version(input, buildid) + self.assertEqual(version, output) + # Some parts of the MSIX packaging ecosystem require the final digit + # in the dotted quad to be 0. + self.assertTrue(version.endswith(".0")) + + buildid = "YYYYMmDdHhMmSs" + for input, output in [ + ("X.0a1", "X.YYMm.DdHh.0"), + ]: + version = get_embedded_version(input, buildid) + self.assertEqual(version, output) + # Some parts of the MSIX packaging ecosystem require the final digit + # in the dotted quad to be 0. + self.assertTrue(version.endswith(".0")) + + for input in [ + "X.Ya1", + "X.0a2", + "X.Y.ZbW", + "X.Y.ZrcW", + ]: + with self.assertRaises(ValueError): + get_embedded_version(input, buildid) + + +if __name__ == "__main__": + main() |