diff options
author | Filipe LaÃns <lains@riseup.net> | 2021-08-17 13:38:48 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-09-06 18:10:55 +0200 |
commit | af8b55d49b64e72dbefbd40d613b93f56d17b855 (patch) | |
tree | ff763c3346d5b7f8f87f41e3f0cb7348ded1a47e /unittests | |
parent | be3bd9ea64570a468d482a8fc70e3d8474f77286 (diff) | |
download | meson-af8b55d49b64e72dbefbd40d613b93f56d17b855.zip meson-af8b55d49b64e72dbefbd40d613b93f56d17b855.tar.gz meson-af8b55d49b64e72dbefbd40d613b93f56d17b855.tar.bz2 |
mintro: add installed_plan
Signed-off-by: Filipe LaÃns <lains@riseup.net>
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/allplatformstests.py | 182 |
1 files changed, 179 insertions, 3 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index bf90bed..6ead45e 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -52,7 +52,7 @@ from mesonbuild.compilers import ( ) from mesonbuild.dependencies import PkgConfigDependency -from mesonbuild.build import Target, ConfigurationData +from mesonbuild.build import Target, ConfigurationData, Executable, SharedLibrary, StaticLibrary import mesonbuild.modules.pkgconfig from mesonbuild.scripts import destdir_join @@ -2837,6 +2837,7 @@ class AllPlatformTests(BasePlatformTests): 'buildsystem_files', 'dependencies', 'installed', + 'install_plan', 'projectinfo', 'targets', 'tests', @@ -3772,7 +3773,7 @@ class AllPlatformTests(BasePlatformTests): self.assertEqual(sorted(link_args), sorted(['-flto'])) def test_install_tag(self) -> None: - testdir = os.path.join(self.unit_test_dir, '98 install tag') + testdir = os.path.join(self.unit_test_dir, '98 install all targets') self.init(testdir) self.build() @@ -3804,29 +3805,36 @@ class AllPlatformTests(BasePlatformTests): expected_devel = expected_common | { Path(installpath, 'usr/include'), - Path(installpath, 'usr/include/foo1-devel.h'), Path(installpath, 'usr/include/bar-devel.h'), + Path(installpath, 'usr/include/bar2-devel.h'), + Path(installpath, 'usr/include/foo1-devel.h'), Path(installpath, 'usr/include/foo2-devel.h'), + Path(installpath, 'usr/include/foo3-devel.h'), Path(installpath, 'usr/include/out-devel.h'), Path(installpath, 'usr/lib'), Path(installpath, 'usr/lib/libstatic.a'), Path(installpath, 'usr/lib/libboth.a'), + Path(installpath, 'usr/lib/libboth2.a'), } if cc.get_id() in {'msvc', 'clang-cl'}: expected_devel |= { Path(installpath, 'usr/bin'), Path(installpath, 'usr/bin/app.pdb'), + Path(installpath, 'usr/bin/app2.pdb'), Path(installpath, 'usr/bin/both.pdb'), + Path(installpath, 'usr/bin/both2.pdb'), Path(installpath, 'usr/bin/bothcustom.pdb'), Path(installpath, 'usr/bin/shared.pdb'), Path(installpath, 'usr/lib/both.lib'), + Path(installpath, 'usr/lib/both2.lib'), Path(installpath, 'usr/lib/bothcustom.lib'), Path(installpath, 'usr/lib/shared.lib'), } elif is_windows() or is_cygwin(): expected_devel |= { Path(installpath, 'usr/lib/libboth.dll.a'), + Path(installpath, 'usr/lib/libboth2.dll.a'), Path(installpath, 'usr/lib/libshared.dll.a'), Path(installpath, 'usr/lib/libbothcustom.dll.a'), } @@ -3834,8 +3842,10 @@ class AllPlatformTests(BasePlatformTests): expected_runtime = expected_common | { Path(installpath, 'usr/bin'), Path(installpath, 'usr/bin/' + exe_name('app')), + Path(installpath, 'usr/bin/' + exe_name('app2')), Path(installpath, 'usr/' + shared_lib_name('shared')), Path(installpath, 'usr/' + shared_lib_name('both')), + Path(installpath, 'usr/' + shared_lib_name('both2')), } expected_custom = expected_common | { @@ -3863,6 +3873,9 @@ class AllPlatformTests(BasePlatformTests): Path(installpath, 'usr/share/out1-notag.txt'), Path(installpath, 'usr/share/out2-notag.txt'), Path(installpath, 'usr/share/out3-notag.txt'), + Path(installpath, 'usr/share/foo2.h'), + Path(installpath, 'usr/share/out1.txt'), + Path(installpath, 'usr/share/out2.txt'), } def do_install(tags=None): @@ -3876,3 +3889,166 @@ class AllPlatformTests(BasePlatformTests): self.assertEqual(sorted(expected_custom), do_install('custom')) self.assertEqual(sorted(expected_runtime_custom), do_install('runtime,custom')) self.assertEqual(sorted(expected_all), do_install()) + + def test_introspect_install_plan(self): + testdir = os.path.join(self.unit_test_dir, '98 install all targets') + introfile = os.path.join(self.builddir, 'meson-info', 'intro-install_plan.json') + self.init(testdir) + self.assertPathExists(introfile) + with open(introfile, encoding='utf-8') as fp: + res = json.load(fp) + + env = get_fake_env(testdir, self.builddir, self.prefix) + + def output_name(name, type_): + return type_(name=name, subdir=None, subproject=None, + for_machine=MachineChoice.HOST, sources=[], + objects=[], environment=env, kwargs={}).filename + + shared_lib_name = lambda name: output_name(name, SharedLibrary) + static_lib_name = lambda name: output_name(name, StaticLibrary) + exe_name = lambda name: output_name(name, Executable) + + expected = { + 'targets': { + f'{self.builddir}/out1-notag.txt': { + 'destination': '{prefix}/share/out1-notag.txt', + 'tag': None, + }, + f'{self.builddir}/out2-notag.txt': { + 'destination': '{prefix}/share/out2-notag.txt', + 'tag': None, + }, + f'{self.builddir}/libstatic.a': { + 'destination': '{libdir_static}/libstatic.a', + 'tag': 'devel', + }, + f'{self.builddir}/' + exe_name('app'): { + 'destination': '{bindir}/' + exe_name('app'), + 'tag': 'runtime', + }, + f'{self.builddir}/subdir/' + exe_name('app2'): { + 'destination': '{bindir}/' + exe_name('app2'), + 'tag': 'runtime', + }, + f'{self.builddir}/' + shared_lib_name('shared'): { + 'destination': '{libdir_shared}/' + shared_lib_name('shared'), + 'tag': 'runtime', + }, + f'{self.builddir}/' + shared_lib_name('both'): { + 'destination': '{libdir_shared}/' + shared_lib_name('both'), + 'tag': 'runtime', + }, + f'{self.builddir}/' + static_lib_name('both'): { + 'destination': '{libdir_static}/' + static_lib_name('both'), + 'tag': 'devel', + }, + f'{self.builddir}/' + shared_lib_name('bothcustom'): { + 'destination': '{libdir_shared}/' + shared_lib_name('bothcustom'), + 'tag': 'custom', + }, + f'{self.builddir}/' + static_lib_name('bothcustom'): { + 'destination': '{libdir_static}/' + static_lib_name('bothcustom'), + 'tag': 'custom', + }, + f'{self.builddir}/subdir/' + shared_lib_name('both2'): { + 'destination': '{libdir_shared}/' + shared_lib_name('both2'), + 'tag': 'runtime', + }, + f'{self.builddir}/subdir/' + static_lib_name('both2'): { + 'destination': '{libdir_static}/' + static_lib_name('both2'), + 'tag': 'devel', + }, + f'{self.builddir}/out1-custom.txt': { + 'destination': '{prefix}/share/out1-custom.txt', + 'tag': 'custom', + }, + f'{self.builddir}/out2-custom.txt': { + 'destination': '{prefix}/share/out2-custom.txt', + 'tag': 'custom', + }, + f'{self.builddir}/out3-custom.txt': { + 'destination': '{prefix}/share/out3-custom.txt', + 'tag': 'custom', + }, + f'{self.builddir}/subdir/out1.txt': { + 'destination': '{prefix}/share/out1.txt', + 'tag': None, + }, + f'{self.builddir}/subdir/out2.txt': { + 'destination': '{prefix}/share/out2.txt', + 'tag': None, + }, + f'{self.builddir}/out-devel.h': { + 'destination': '{prefix}/include/out-devel.h', + 'tag': 'devel', + }, + f'{self.builddir}/out3-notag.txt': { + 'destination': '{prefix}/share/out3-notag.txt', + 'tag': None, + }, + }, + 'configure': { + f'{self.builddir}/foo-notag.h': { + 'destination': '{prefix}/share/foo-notag.h', + 'tag': None, + }, + f'{self.builddir}/foo2-devel.h': { + 'destination': '{prefix}/include/foo2-devel.h', + 'tag': 'devel', + }, + f'{self.builddir}/foo-custom.h': { + 'destination': '{prefix}/share/foo-custom.h', + 'tag': 'custom', + }, + f'{self.builddir}/subdir/foo2.h': { + 'destination': '{prefix}/share/foo2.h', + 'tag': None, + }, + }, + 'data': { + f'{testdir}/bar-notag.txt': { + 'destination': '{datadir}/share/bar-notag.txt', + 'tag': None, + }, + f'{testdir}/bar-devel.h': { + 'destination': '{datadir}/include/bar-devel.h', + 'tag': 'devel', + }, + f'{testdir}/bar-custom.txt': { + 'destination': '{datadir}/share/bar-custom.txt', + 'tag': 'custom', + }, + f'{testdir}/subdir/bar2-devel.h': { + 'destination': '{datadir}/include/bar2-devel.h', + 'tag': 'devel', + }, + }, + 'headers': { + f'{testdir}/foo1-devel.h': { + 'destination': '{includedir}/foo1-devel.h', + 'tag': 'devel', + }, + f'{testdir}/subdir/foo3-devel.h': { + 'destination': '{includedir}/foo3-devel.h', + 'tag': 'devel', + }, + } + } + + fix_path = lambda path: os.path.sep.join(path.split('/')) + expected_fixed = { + data_type: { + fix_path(source): { + key: fix_path(value) if key == 'destination' else value + for key, value in attributes.items() + } + for source, attributes in files.items() + } + for data_type, files in expected.items() + } + + for data_type, files in expected_fixed.items(): + for file, details in files.items(): + with self.subTest(key='{}.{}'.format(data_type, file)): + self.assertEqual(res[data_type][file], details) |