diff options
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/__init__.py | 20 | ||||
-rw-r--r-- | unittests/allplatformstests.py | 20 | ||||
-rw-r--r-- | unittests/optiontests.py | 24 |
3 files changed, 56 insertions, 8 deletions
diff --git a/unittests/__init__.py b/unittests/__init__.py index e69de29..fb8fb8e 100644 --- a/unittests/__init__.py +++ b/unittests/__init__.py @@ -0,0 +1,20 @@ +import os + +import mesonbuild.compilers +from mesonbuild.mesonlib import setup_vsenv + +def unset_envs(): + # For unit tests we must fully control all command lines + # so that there are no unexpected changes coming from the + # environment, for example when doing a package build. + varnames = ['CPPFLAGS', 'LDFLAGS'] + list(mesonbuild.compilers.compilers.CFLAGS_MAPPING.values()) + for v in varnames: + if v in os.environ: + del os.environ[v] + +def set_envs(): + os.environ.setdefault('MESON_UNIT_TEST_BACKEND', 'ninja') + +setup_vsenv() +unset_envs() +set_envs() diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 905ae4d..c006961 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -4812,120 +4812,140 @@ class AllPlatformTests(BasePlatformTests): expected = { 'targets': { get_path(f'{self.builddir}/out1-notag.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out1-notag.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, get_path(f'{self.builddir}/out2-notag.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out2-notag.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, get_path(f'{self.builddir}/libstatic.a'): { + 'build_rpaths': [], 'destination': '{libdir_static}/libstatic.a', 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, get_path(f'{self.builddir}/' + exe_name('app')): { + 'build_rpaths': [], 'destination': '{bindir}/' + exe_name('app'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, get_path(f'{self.builddir}/' + exe_name('app-otherdir')): { + 'build_rpaths': [], 'destination': '{prefix}/otherbin/' + exe_name('app-otherdir'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, get_path(f'{self.builddir}/subdir/' + exe_name('app2')): { + 'build_rpaths': [], 'destination': '{bindir}/' + exe_name('app2'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, get_path(f'{self.builddir}/' + shared_lib_name('shared')): { + 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('shared'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, get_path(f'{self.builddir}/' + shared_lib_name('both')): { + 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('both'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, get_path(f'{self.builddir}/' + static_lib_name('both')): { + 'build_rpaths': [], 'destination': '{libdir_static}/' + static_lib_name('both'), 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, get_path(f'{self.builddir}/' + shared_lib_name('bothcustom')): { + 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('bothcustom'), 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, get_path(f'{self.builddir}/' + static_lib_name('bothcustom')): { + 'build_rpaths': [], 'destination': '{libdir_static}/' + static_lib_name('bothcustom'), 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, get_path(f'{self.builddir}/subdir/' + shared_lib_name('both2')): { + 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('both2'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, get_path(f'{self.builddir}/subdir/' + static_lib_name('both2')): { + 'build_rpaths': [], 'destination': '{libdir_static}/' + static_lib_name('both2'), 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, get_path(f'{self.builddir}/out1-custom.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out1-custom.txt', 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, get_path(f'{self.builddir}/out2-custom.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out2-custom.txt', 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, get_path(f'{self.builddir}/out3-custom.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out3-custom.txt', 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, get_path(f'{self.builddir}/subdir/out1.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out1.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, get_path(f'{self.builddir}/subdir/out2.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out2.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, get_path(f'{self.builddir}/out-devel.h'): { + 'build_rpaths': [], 'destination': '{includedir}/out-devel.h', 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, get_path(f'{self.builddir}/out3-notag.txt'): { + 'build_rpaths': [], 'destination': '{datadir}/out3-notag.txt', 'install_rpath': None, 'tag': None, diff --git a/unittests/optiontests.py b/unittests/optiontests.py index 3fb44b7..30e5f03 100644 --- a/unittests/optiontests.py +++ b/unittests/optiontests.py @@ -121,6 +121,14 @@ class OptionTests(unittest.TestCase): self.assertEqual(optstore.get_value_for(name, 'sub'), sub_value) self.assertEqual(num_options(optstore), 2) + def test_toplevel_project_yielding(self): + optstore = OptionStore(False) + name = 'someoption' + top_value = 'top' + vo = UserStringOption(name, 'A top level option', top_value, True) + optstore.add_project_option(OptionKey(name, ''), vo) + self.assertEqual(optstore.get_value_for(name, ''), top_value) + def test_project_yielding(self): optstore = OptionStore(False) name = 'someoption' @@ -174,7 +182,7 @@ class OptionTests(unittest.TestCase): optstore.initialize_from_subproject_call(subp, {}, {}, cmd_line, {}) self.assertEqual(optstore.get_value_for(name, ''), top_value) - self.assertEqual(optstore.get_value_for(name, subp), top_value) + self.assertEqual(optstore.get_value_for(name, subp), sub_value) def test_augments(self): optstore = OptionStore(False) @@ -195,25 +203,25 @@ class OptionTests(unittest.TestCase): # First augment a subproject with self.subTest('set subproject override'): - optstore.set_from_configure_command([f'{sub_name}:{name}={aug_value}'], []) + optstore.set_from_configure_command({OptionKey.from_string(f'{sub_name}:{name}'): aug_value}) self.assertEqual(optstore.get_value_for(name), top_value) self.assertEqual(optstore.get_value_for(name, sub_name), aug_value) self.assertEqual(optstore.get_value_for(name, sub2_name), top_value) with self.subTest('unset subproject override'): - optstore.set_from_configure_command([], [f'{sub_name}:{name}']) + optstore.set_from_configure_command({OptionKey.from_string(f'{sub_name}:{name}'): None}) self.assertEqual(optstore.get_value_for(name), top_value) self.assertEqual(optstore.get_value_for(name, sub_name), top_value) self.assertEqual(optstore.get_value_for(name, sub2_name), top_value) # And now augment the top level option - optstore.set_from_configure_command([f':{name}={aug_value}'], []) + optstore.set_from_configure_command({OptionKey.from_string(f':{name}'): aug_value}) self.assertEqual(optstore.get_value_for(name, None), top_value) self.assertEqual(optstore.get_value_for(name, ''), aug_value) self.assertEqual(optstore.get_value_for(name, sub_name), top_value) self.assertEqual(optstore.get_value_for(name, sub2_name), top_value) - optstore.set_from_configure_command([], [f':{name}']) + optstore.set_from_configure_command({OptionKey.from_string(f':{name}'): None}) self.assertEqual(optstore.get_value_for(name), top_value) self.assertEqual(optstore.get_value_for(name, sub_name), top_value) self.assertEqual(optstore.get_value_for(name, sub2_name), top_value) @@ -233,8 +241,8 @@ class OptionTests(unittest.TestCase): choices=['c++98', 'c++11', 'c++14', 'c++17', 'c++20', 'c++23'], ) optstore.add_system_option(name, co) - optstore.set_from_configure_command([f'{sub_name}:{name}={aug_value}'], []) - optstore.set_from_configure_command([f'{sub_name}:{name}={set_value}'], []) + optstore.set_from_configure_command({OptionKey.from_string(f'{sub_name}:{name}'): aug_value}) + optstore.set_from_configure_command({OptionKey.from_string(f'{sub_name}:{name}'): set_value}) self.assertEqual(optstore.get_value_for(name), top_value) self.assertEqual(optstore.get_value_for(name, sub_name), set_value) @@ -256,7 +264,7 @@ class OptionTests(unittest.TestCase): def test_reconfigure_b_nonexistent(self): optstore = OptionStore(False) - optstore.set_from_configure_command(['b_ndebug=true'], []) + optstore.set_from_configure_command({OptionKey('b_ndebug'): True}) def test_subproject_proj_opt_with_same_name(self): name = 'tests' |