diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/mozharness/test/test_mozilla_building_buildbase.py | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozharness/test/test_mozilla_building_buildbase.py')
-rw-r--r-- | testing/mozharness/test/test_mozilla_building_buildbase.py | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/testing/mozharness/test/test_mozilla_building_buildbase.py b/testing/mozharness/test/test_mozilla_building_buildbase.py new file mode 100644 index 0000000000..483196d094 --- /dev/null +++ b/testing/mozharness/test/test_mozilla_building_buildbase.py @@ -0,0 +1,146 @@ +import os +import unittest + +from mozharness.base.log import LogMixin +from mozharness.base.script import ScriptMixin +from mozharness.mozilla.building.buildbase import MozconfigPathError, get_mozconfig_path + + +class FakeLogger(object): + def log_message(self, *args, **kwargs): + pass + + +class FakeScriptMixin(LogMixin, ScriptMixin, object): + def __init__(self): + self.script_obj = self + self.log_obj = FakeLogger() + + +class TestMozconfigPath(unittest.TestCase): + """ + Tests for :func:`get_mozconfig_path`. + """ + + def test_path(self): + """ + Passing just ``src_mozconfig`` gives that file in ``abs_src_dir``. + """ + script = FakeScriptMixin() + + abs_src_path = get_mozconfig_path( + script, + config={"src_mozconfig": "path/to/mozconfig"}, + dirs={"abs_src_dir": "/src"}, + ) + self.assertEqual(abs_src_path, "/src/path/to/mozconfig") + + def test_composite(self): + """ + Passing ``app_name``, ``mozconfig_platform``, and ``mozconfig_variant`` + find the file in the ``config/mozconfigs`` subdirectory of that app + directory. + """ + script = FakeScriptMixin() + + config = { + "app_name": "the-app", + "mozconfig_variant": "variant", + "mozconfig_platform": "platform9000", + } + abs_src_path = get_mozconfig_path( + script, + config=config, + dirs={"abs_src_dir": "/src"}, + ) + self.assertEqual( + abs_src_path, + "/src/the-app/config/mozconfigs/platform9000/variant", + ) + + def test_manifest(self): + """ + Passing just ``src_mozconfig_manifest`` looks in that file in + ``abs_work_dir``, and finds the mozconfig file specified there in + ``abs_src_dir``. + """ + script = FakeScriptMixin() + + test_dir = os.path.dirname(__file__) + config = {"src_mozconfig_manifest": "helper_files/mozconfig_manifest.json"} + abs_src_path = get_mozconfig_path( + script, + config=config, + dirs={ + "abs_src_dir": "/src", + "abs_work_dir": test_dir, + }, + ) + self.assertEqual(abs_src_path, "/src/path/to/mozconfig") + + def test_errors(self): + script = FakeScriptMixin() + + configs = [ + # Not specifying any parts of a mozconfig path + {}, + # Specifying both src_mozconfig and src_mozconfig_manifest + {"src_mozconfig": "path", "src_mozconfig_manifest": "path"}, + # Specifying src_mozconfig with some or all of a composite + # mozconfig path + { + "src_mozconfig": "path", + "app_name": "app", + "mozconfig_platform": "platform", + "mozconfig_variant": "variant", + }, + { + "src_mozconfig": "path", + "mozconfig_platform": "platform", + "mozconfig_variant": "variant", + }, + { + "src_mozconfig": "path", + "app_name": "app", + "mozconfig_variant": "variant", + }, + { + "src_mozconfig": "path", + "app_name": "app", + "mozconfig_platform": "platform", + }, + # Specifying src_mozconfig_manifest with some or all of a composite + # mozconfig path + { + "src_mozconfig_manifest": "path", + "app_name": "app", + "mozconfig_platform": "platform", + "mozconfig_variant": "variant", + }, + { + "src_mozconfig_manifest": "path", + "mozconfig_platform": "platform", + "mozconfig_variant": "variant", + }, + { + "src_mozconfig_manifest": "path", + "app_name": "app", + "mozconfig_variant": "variant", + }, + { + "src_mozconfig_manifest": "path", + "app_name": "app", + "mozconfig_platform": "platform", + }, + # Specifying only some parts of a compsite mozconfig path + {"mozconfig_platform": "platform", "mozconfig_variant": "variant"}, + {"app_name": "app", "mozconfig_variant": "variant"}, + {"app_name": "app", "mozconfig_platform": "platform"}, + {"app_name": "app"}, + {"mozconfig_variant": "variant"}, + {"mozconfig_platform": "platform"}, + ] + + for config in configs: + with self.assertRaises(MozconfigPathError): + get_mozconfig_path(script, config=config, dirs={}) |