diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2024-06-09 01:03:49 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2024-06-14 17:19:53 +0300 |
commit | 9a6fcd4d9a0c7bb248c5d0587632b741a3301e03 (patch) | |
tree | f066ab0ee942d2f12579bb075cb3afbdf3386f0b /unittests | |
parent | c0d86024f5e647858f88bc400b45b3ad88a25c97 (diff) | |
download | meson-9a6fcd4d9a0c7bb248c5d0587632b741a3301e03.zip meson-9a6fcd4d9a0c7bb248c5d0587632b741a3301e03.tar.gz meson-9a6fcd4d9a0c7bb248c5d0587632b741a3301e03.tar.bz2 |
Replace direct indexing with named methods.
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/allplatformstests.py | 60 | ||||
-rw-r--r-- | unittests/datatests.py | 6 | ||||
-rw-r--r-- | unittests/internaltests.py | 2 | ||||
-rw-r--r-- | unittests/linuxliketests.py | 2 |
4 files changed, 35 insertions, 35 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 042f210..201dae6 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -2621,35 +2621,35 @@ class AllPlatformTests(BasePlatformTests): out = self.init(testdir, extra_args=['--profile-self', '--fatal-meson-warnings']) self.assertNotIn('[default: true]', out) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('default_library')].value, 'static') - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '1') - self.assertEqual(obj.optstore[OptionKey('set_sub_opt')].value, True) - self.assertEqual(obj.optstore[OptionKey('subp_opt', 'subp')].value, 'default3') + self.assertEqual(obj.optstore.get_value('default_library'), 'static') + self.assertEqual(obj.optstore.get_value('warning_level'), '1') + self.assertEqual(obj.optstore.get_value('set_sub_opt'), True) + self.assertEqual(obj.optstore.get_value(OptionKey('subp_opt', 'subp')), 'default3') self.wipe() # warning_level is special, it's --warnlevel instead of --warning-level # for historical reasons self.init(testdir, extra_args=['--warnlevel=2', '--fatal-meson-warnings']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '2') + self.assertEqual(obj.optstore.get_value('warning_level'), '2') self.setconf('--warnlevel=3') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '3') + self.assertEqual(obj.optstore.get_value('warning_level'), '3') self.setconf('--warnlevel=everything') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, 'everything') + self.assertEqual(obj.optstore.get_value('warning_level'), 'everything') self.wipe() # But when using -D syntax, it should be 'warning_level' self.init(testdir, extra_args=['-Dwarning_level=2', '--fatal-meson-warnings']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '2') + self.assertEqual(obj.optstore.get_value('warning_level'), '2') self.setconf('-Dwarning_level=3') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '3') + self.assertEqual(obj.optstore.get_value('warning_level'), '3') self.setconf('-Dwarning_level=everything') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, 'everything') + self.assertEqual(obj.optstore.get_value('warning_level'), 'everything') self.wipe() # Mixing --option and -Doption is forbidden @@ -2673,15 +2673,15 @@ class AllPlatformTests(BasePlatformTests): # --default-library should override default value from project() self.init(testdir, extra_args=['--default-library=both', '--fatal-meson-warnings']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('default_library')].value, 'both') + self.assertEqual(obj.optstore.get_value('default_library'), 'both') self.setconf('--default-library=shared') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('default_library')].value, 'shared') + self.assertEqual(obj.optstore.get_value('default_library'), 'shared') if self.backend is Backend.ninja: # reconfigure target works only with ninja backend self.build('reconfigure') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('default_library')].value, 'shared') + self.assertEqual(obj.optstore.get_value('default_library'), 'shared') self.wipe() # Should fail on unknown options @@ -2718,22 +2718,22 @@ class AllPlatformTests(BasePlatformTests): # Test we can set subproject option self.init(testdir, extra_args=['-Dsubp:subp_opt=foo', '--fatal-meson-warnings']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('subp_opt', 'subp')].value, 'foo') + self.assertEqual(obj.optstore.get_value(OptionKey('subp_opt', 'subp')), 'foo') self.wipe() # c_args value should be parsed with split_args self.init(testdir, extra_args=['-Dc_args=-Dfoo -Dbar "-Dthird=one two"', '--fatal-meson-warnings']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('args', lang='c')].value, ['-Dfoo', '-Dbar', '-Dthird=one two']) + self.assertEqual(obj.optstore.get_value(OptionKey('args', lang='c')), ['-Dfoo', '-Dbar', '-Dthird=one two']) self.setconf('-Dc_args="foo bar" one two') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('args', lang='c')].value, ['foo bar', 'one', 'two']) + self.assertEqual(obj.optstore.get_value(OptionKey('args', lang='c')), ['foo bar', 'one', 'two']) self.wipe() self.init(testdir, extra_args=['-Dset_percent_opt=myoption%', '--fatal-meson-warnings']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('set_percent_opt')].value, 'myoption%') + self.assertEqual(obj.optstore.get_value('set_percent_opt'), 'myoption%') self.wipe() # Setting a 2nd time the same option should override the first value @@ -2744,19 +2744,19 @@ class AllPlatformTests(BasePlatformTests): '-Dc_args=-Dfoo', '-Dc_args=-Dbar', '-Db_lundef=false', '--fatal-meson-warnings']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('bindir')].value, 'bar') - self.assertEqual(obj.optstore[OptionKey('buildtype')].value, 'release') - self.assertEqual(obj.optstore[OptionKey('b_sanitize')].value, 'thread') - self.assertEqual(obj.optstore[OptionKey('args', lang='c')].value, ['-Dbar']) + self.assertEqual(obj.optstore.get_value('bindir'), 'bar') + self.assertEqual(obj.optstore.get_value('buildtype'), 'release') + self.assertEqual(obj.optstore.get_value('b_sanitize'), 'thread') + self.assertEqual(obj.optstore.get_value(OptionKey('args', lang='c')), ['-Dbar']) self.setconf(['--bindir=bar', '--bindir=foo', '-Dbuildtype=release', '-Dbuildtype=plain', '-Db_sanitize=thread', '-Db_sanitize=address', '-Dc_args=-Dbar', '-Dc_args=-Dfoo']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('bindir')].value, 'foo') - self.assertEqual(obj.optstore[OptionKey('buildtype')].value, 'plain') - self.assertEqual(obj.optstore[OptionKey('b_sanitize')].value, 'address') - self.assertEqual(obj.optstore[OptionKey('args', lang='c')].value, ['-Dfoo']) + self.assertEqual(obj.optstore.get_value('bindir'), 'foo') + self.assertEqual(obj.optstore.get_value('buildtype'), 'plain') + self.assertEqual(obj.optstore.get_value('b_sanitize'), 'address') + self.assertEqual(obj.optstore.get_value(OptionKey('args', lang='c')), ['-Dfoo']) self.wipe() except KeyError: # Ignore KeyError, it happens on CI for compilers that does not @@ -2770,25 +2770,25 @@ class AllPlatformTests(BasePlatformTests): # Verify default values when passing no args self.init(testdir) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '0') + self.assertEqual(obj.optstore.get_value('warning_level'), '0') self.wipe() # verify we can override w/ --warnlevel self.init(testdir, extra_args=['--warnlevel=1']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '1') + self.assertEqual(obj.optstore.get_value('warning_level'), '1') self.setconf('--warnlevel=0') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '0') + self.assertEqual(obj.optstore.get_value('warning_level'), '0') self.wipe() # verify we can override w/ -Dwarning_level self.init(testdir, extra_args=['-Dwarning_level=1']) obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '1') + self.assertEqual(obj.optstore.get_value('warning_level'), '1') self.setconf('-Dwarning_level=0') obj = mesonbuild.coredata.load(self.builddir) - self.assertEqual(obj.optstore[OptionKey('warning_level')].value, '0') + self.assertEqual(obj.optstore.get_value('warning_level'), '0') self.wipe() def test_feature_check_usage_subprojects(self): diff --git a/unittests/datatests.py b/unittests/datatests.py index b596446..b7b2d32 100644 --- a/unittests/datatests.py +++ b/unittests/datatests.py @@ -163,9 +163,9 @@ class DataTests(unittest.TestCase): else: raise RuntimeError(f'Invalid debug value {debug!r} in row:\n{m.group()}') env.coredata.set_option(OptionKey('buildtype'), buildtype) - self.assertEqual(env.coredata.optstore[OptionKey('buildtype')].value, buildtype) - self.assertEqual(env.coredata.optstore[OptionKey('optimization')].value, opt) - self.assertEqual(env.coredata.optstore[OptionKey('debug')].value, debug) + self.assertEqual(env.coredata.optstore.get_value('buildtype'), buildtype) + self.assertEqual(env.coredata.optstore.get_value('optimization'), opt) + self.assertEqual(env.coredata.optstore.get_value('debug'), debug) def test_cpu_families_documented(self): with open("docs/markdown/Reference-tables.md", encoding='utf-8') as f: diff --git a/unittests/internaltests.py b/unittests/internaltests.py index 42cc41e..fe9f0d4 100644 --- a/unittests/internaltests.py +++ b/unittests/internaltests.py @@ -625,7 +625,7 @@ class InternalTests(unittest.TestCase): env = get_fake_env() compiler = detect_c_compiler(env, MachineChoice.HOST) env.coredata.compilers.host = {'c': compiler} - env.coredata.optstore[OptionKey('link_args', lang='c')] = FakeCompilerOptions() + env.coredata.optstore.set_value_object(OptionKey('link_args', lang='c'), FakeCompilerOptions()) p1 = Path(tmpdir) / '1' p2 = Path(tmpdir) / '2' p1.mkdir() diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 1e8038f..ea86784 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -1124,7 +1124,7 @@ class LinuxlikeTests(BasePlatformTests): # option, adding the meson-uninstalled directory to it. PkgConfigInterface.setup_env({}, env, MachineChoice.HOST, uninstalled=True) - pkg_config_path = env.coredata.optstore[OptionKey('pkg_config_path')].value + pkg_config_path = env.coredata.optstore.get_value('pkg_config_path') self.assertEqual(pkg_config_path, [pkg_dir]) @skipIfNoPkgconfig |