From 7ef9f48ad9aa144a55f258d2a57792a1439be61a Mon Sep 17 00:00:00 2001 From: Scarlett Moore Date: Fri, 4 Oct 2024 01:50:55 -0700 Subject: [PATCH] kde-neon-6: Fix tests. --- snapcraft/extensions/kde_neon_6.py | 34 ++-- tests/unit/commands/test_list_extensions.py | 4 +- tests/unit/extensions/test_kde_neon_6.py | 181 ++++++++++++++++++-- 3 files changed, 183 insertions(+), 36 deletions(-) diff --git a/snapcraft/extensions/kde_neon_6.py b/snapcraft/extensions/kde_neon_6.py index 0d426f695e..505b6b525c 100644 --- a/snapcraft/extensions/kde_neon_6.py +++ b/snapcraft/extensions/kde_neon_6.py @@ -26,14 +26,8 @@ from .extension import Extension, get_extensions_data_dir, prepend_to_env -_QT6_SDK_SNAP = { - "core22": "kde-qt6-core22-sdk", - "core24": "kde-qt6-core24-sdk" - } -_KF6_SDK_SNAP = { - "core22": "kf6-core22-sdk", - "core24": "kf6-core24-sdk" - } +_QT6_SDK_SNAP = {"core22": "kde-qt6-core22-sdk", "core24": "kde-qt6-core24-sdk"} +_KF6_SDK_SNAP = {"core22": "kf6-core22-sdk", "core24": "kf6-core24-sdk"} @dataclasses.dataclass @@ -44,6 +38,8 @@ class KDESnaps6: kf6_sdk_snap: str content_qt6: str content_kf6: str + gpu_plugs: Dict[str, Any] + gpu_layouts: Dict[str, Any] qt6_builtin: bool = True kf6_builtin: bool = True @@ -58,8 +54,10 @@ class KDENeon6(Extension): \b - Common GTK themes. + - breeze GTK theme. - Common Qt themes. - Common Icon Themes. + - Breeze Icon theme. - Common Sound Themes. - The Qt6 and KDE Frameworks 6 runtime libraries and utilities. @@ -95,11 +93,11 @@ def is_experimental(base: Optional[str]) -> bool: @overrides def get_app_snippet(self) -> Dict[str, Any]: - command_chain = ["snap/command-chain/desktop-launch"] + command_chain = ["snap/command-chain/desktop-launch6"] if self.yaml_data["base"] == "core24": command_chain.insert(0, "snap/command-chain/gpu-2404-wrapper") return { - "command-chain": commandchain, + "command-chain": command_chain, "plugs": [ "desktop", "desktop-legacy", @@ -124,9 +122,7 @@ def kde_snaps(self) -> KDESnaps6: case "core22": gpu_plugs = {} gpu_layouts = { - "/usr/share/libdrm": { - "bind": "$SNAP/kf6-core22/usr/share/libdrm" - }, + "/usr/share/libdrm": {"bind": "$SNAP/kf6-core22/usr/share/libdrm"}, } case "core24": gpu_plugs = { @@ -176,12 +172,16 @@ def kde_snaps(self) -> KDESnaps6: kf6_sdk_snap=kf6_sdk_snap, content_kf6=content_kf6_snap, kf6_builtin=kf6_builtin, + gpu_layouts=gpu_layouts, + gpu_plugs=gpu_plugs, ) @overrides def get_root_snippet(self) -> Dict[str, Any]: platform_kf6_snap = self.kde_snaps.content_kf6 content_kf6_snap = self.kde_snaps.content_kf6 + "-all" + gpu_plugs = self.kde_snaps.gpu_plugs + gpu_layouts = self.kde_snaps.gpu_layouts return { "assumes": ["snapd2.58.3"], # for 'snapctl is-connected' @@ -193,7 +193,7 @@ def get_root_snippet(self) -> Dict[str, Any]: "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, - "gtk-theme-breeze": { + "gtk-2-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/themes", "default-provider": "gtk-theme-breeze", @@ -203,6 +203,11 @@ def get_root_snippet(self) -> Dict[str, Any]: "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, + "gtk-3-theme-breeze": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-theme-breeze", + }, "icon-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/icons", @@ -353,7 +358,6 @@ def get_parts_snippet(self) -> Dict[str, Any]: if self.yaml_data["base"] == "core24": gpu_opts["make-parameters"] = ["GPU_WRAPPER=gpu-2404-wrapper"] - if self.kde_snaps.kf6_builtin: return { "kde-neon-6/sdk": { diff --git a/tests/unit/commands/test_list_extensions.py b/tests/unit/commands/test_list_extensions.py index 1900e1a4d7..81dbaa9a16 100644 --- a/tests/unit/commands/test_list_extensions.py +++ b/tests/unit/commands/test_list_extensions.py @@ -48,7 +48,7 @@ def test_command(emitter, command): gnome-3-34 core18 gnome-3-38 core20 kde-neon core18, core20, core22 - kde-neon-6 core22 + kde-neon-6 core22, core24 ros1-noetic core20 ros1-noetic-desktop core20 ros1-noetic-perception core20 @@ -96,7 +96,7 @@ def test_command_extension_dups(emitter, command): gnome-3-34 core18 gnome-3-38 core20 kde-neon core18, core20, core22 - kde-neon-6 core22 + kde-neon-6 core22, core24 ros1-noetic core20 ros1-noetic-desktop core20 ros1-noetic-perception core20 diff --git a/tests/unit/extensions/test_kde_neon_6.py b/tests/unit/extensions/test_kde_neon_6.py index c84145b86d..9d73fb1bb3 100644 --- a/tests/unit/extensions/test_kde_neon_6.py +++ b/tests/unit/extensions/test_kde_neon_6.py @@ -32,7 +32,7 @@ def kde_neon_6_extension(): ) -@pytest.fixtureS +@pytest.fixture def kde_neon_6_extension_core24(): return kde_neon_6.KDENeon6( yaml_data={"base": "core24", "parts": {}}, arch="amd64", target_arch="amd64" @@ -96,6 +96,25 @@ def kde_neon_6_extension_with_default_build_snap_from_latest_edge(): ) +@pytest.fixture +def kde_neon_6_extension_with_default_build_snap_from_latest_edge_core24(): + return kde_neon_6.KDENeon6( + yaml_data={ + "base": "core24", + "parts": { + "part1": { + "build-snaps": [ + "kde-qt6-core24-sdk/latest/edge", + "kf6-core24-sdk/latest/edge", + ] + } + }, + }, + arch="amd64", + target_arch="amd64", + ) + + ################### # KDENeon6 Extension # ################### @@ -130,6 +149,7 @@ def test_get_app_snippet(kde_neon_6_extension): } +def test_get_app_snippet_core24(kde_neon_6_extension_core24): assert kde_neon_6_extension_core24.get_app_snippet() == { "command-chain": [ "snap/command-chain/gpu-2404-wrapper", @@ -163,6 +183,7 @@ def test_get_root_snippet(kde_neon_6_extension): "layout": { "/usr/share/X11": {"symlink": "$SNAP/kf6/usr/share/X11"}, "/usr/share/qt6": {"symlink": "$SNAP/kf6/usr/share/qt6"}, + "/usr/share/libdrm": {"bind": "$SNAP/kf6-core22/usr/share/libdrm"}, }, "plugs": { "desktop": {"mount-host-font-cache": False}, @@ -171,7 +192,7 @@ def test_get_root_snippet(kde_neon_6_extension): "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, - "gtk-theme-breeze": { + "gtk-2-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/themes", "default-provider": "gtk-theme-breeze", @@ -181,10 +202,16 @@ def test_get_root_snippet(kde_neon_6_extension): "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, + "gtk-3-theme-breeze": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-theme-breeze", + }, "icon-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/icons", "default-provider": "icon-theme-breeze", + }, "icon-themes": { "interface": "content", "target": "$SNAP/data-dir/icons", @@ -212,6 +239,10 @@ def test_get_root_snippet(kde_neon_6_extension): "target": "$SNAP/kf6", }, }, + } + + +def test_get_root_snippet_core24(kde_neon_6_extension_core24): assert kde_neon_6_extension_core24.get_root_snippet() == { "assumes": ["snapd2.58.3"], "compression": "lzo", @@ -219,12 +250,15 @@ def test_get_root_snippet(kde_neon_6_extension): "hooks": { "configure": { "plugs": ["desktop"], - "command-chain": ["snap/command-chain/hooks-configure-fonts"], + "command-chain": ["snap/command-chain/hooks-configure-desktop"], } }, "layout": { "/usr/share/X11": {"symlink": "$SNAP/kf6/usr/share/X11"}, "/usr/share/qt6": {"symlink": "$SNAP/kf6/usr/share/qt6"}, + "/usr/share/libdrm": {"bind": "$SNAP/gpu-2404/libdrm"}, + "/usr/share/drirc.d": {"symlink": "$SNAP/gpu-2404/drirc.d"}, + "/usr/share/X11/XErrorDB": {"symlink": "$SNAP/gpu-2404/X11/XErrorDB"}, }, "plugs": { "desktop": {"mount-host-font-cache": False}, @@ -233,7 +267,7 @@ def test_get_root_snippet(kde_neon_6_extension): "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, - "gtk-theme-breeze": { + "gtk-2-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/themes", "default-provider": "gtk-theme-breeze", @@ -243,10 +277,16 @@ def test_get_root_snippet(kde_neon_6_extension): "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, + "gtk-3-theme-breeze": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-theme-breeze", + }, "icon-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/icons", "default-provider": "icon-theme-breeze", + }, "icon-themes": { "interface": "content", "target": "$SNAP/data-dir/icons", @@ -273,9 +313,15 @@ def test_get_root_snippet(kde_neon_6_extension): "default-provider": "kf6-core24", "target": "$SNAP/kf6", }, + "gpu-2404": { + "default-provider": "mesa-2404", + "interface": "content", + "target": "$SNAP/gpu-2404", + }, }, } + def test_get_root_snippet_with_gpu(kde_neon_6_extension_core24): snippet = kde_neon_6_extension_core24.get_root_snippet() assert snippet["plugs"]["gpu-2404"] == { @@ -302,12 +348,13 @@ def test_get_root_snippet_with_external_sdk(kde_neon_6_extension_with_build_snap "hooks": { "configure": { "plugs": ["desktop"], - "command-chain": ["snap/command-chain/hooks-configure-fonts"], + "command-chain": ["snap/command-chain/hooks-configure-desktop"], } }, "layout": { "/usr/share/X11": {"symlink": "$SNAP/kf6/usr/share/X11"}, "/usr/share/qt6": {"symlink": "$SNAP/kf6/usr/share/qt6"}, + "/usr/share/libdrm": {"bind": "$SNAP/kf6-core22/usr/share/libdrm"}, }, "plugs": { "desktop": {"mount-host-font-cache": False}, @@ -316,7 +363,7 @@ def test_get_root_snippet_with_external_sdk(kde_neon_6_extension_with_build_snap "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, - "gtk-theme-breeze": { + "gtk-2-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/themes", "default-provider": "gtk-theme-breeze", @@ -326,10 +373,16 @@ def test_get_root_snippet_with_external_sdk(kde_neon_6_extension_with_build_snap "target": "$SNAP/data-dir/themes", "default-provider": "gtk-common-themes", }, + "gtk-3-theme-breeze": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-theme-breeze", + }, "icon-theme-breeze": { "interface": "content", "target": "$SNAP/data-dir/icons", "default-provider": "icon-theme-breeze", + }, "icon-themes": { "interface": "content", "target": "$SNAP/data-dir/icons", @@ -360,6 +413,88 @@ def test_get_root_snippet_with_external_sdk(kde_neon_6_extension_with_build_snap } +def test_get_root_snippet_with_external_sdk_core24( + kde_neon_6_extension_with_build_snap_core24, +): + assert kde_neon_6_extension_with_build_snap_core24.get_root_snippet() == { + "assumes": ["snapd2.58.3"], + "compression": "lzo", + "environment": {"SNAP_DESKTOP_RUNTIME": "$SNAP/kf6"}, + "hooks": { + "configure": { + "plugs": ["desktop"], + "command-chain": ["snap/command-chain/hooks-configure-desktop"], + } + }, + "layout": { + "/usr/share/X11": {"symlink": "$SNAP/kf6/usr/share/X11"}, + "/usr/share/qt6": {"symlink": "$SNAP/kf6/usr/share/qt6"}, + "/usr/share/libdrm": {"bind": "$SNAP/gpu-2404/libdrm"}, + "/usr/share/drirc.d": {"symlink": "$SNAP/gpu-2404/drirc.d"}, + "/usr/share/X11/XErrorDB": {"symlink": "$SNAP/gpu-2404/X11/XErrorDB"}, + }, + "plugs": { + "desktop": {"mount-host-font-cache": False}, + "gtk-2-themes": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-common-themes", + }, + "gtk-2-theme-breeze": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-theme-breeze", + }, + "gtk-3-themes": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-common-themes", + }, + "gtk-3-theme-breeze": { + "interface": "content", + "target": "$SNAP/data-dir/themes", + "default-provider": "gtk-theme-breeze", + }, + "icon-theme-breeze": { + "interface": "content", + "target": "$SNAP/data-dir/icons", + "default-provider": "icon-theme-breeze", + }, + "icon-themes": { + "interface": "content", + "target": "$SNAP/data-dir/icons", + "default-provider": "gtk-common-themes", + }, + "qt-sound-themes": { + "interface": "content", + "target": "$SNAP/data-dir/sounds", + "default-provider": "qt-common-themes", + }, + "sound-themes": { + "interface": "content", + "target": "$SNAP/data-dir/sounds", + "default-provider": "gtk-common-themes", + }, + "qt-6-themes": { + "interface": "content", + "target": "$SNAP/kf6", + "default-provider": "qt-common-themes", + }, + "kf6-core24": { + "content": "kf6-core24-all", + "interface": "content", + "default-provider": "kf6-core24", + "target": "$SNAP/kf6", + }, + "gpu-2404": { + "default-provider": "mesa-2404", + "interface": "content", + "target": "$SNAP/gpu-2404", + }, + }, + } + + class TestGetPartSnippet: """Tests for KDENeon6.get_part_snippet when using the default sdk snap name.""" @@ -501,11 +636,13 @@ def test_get_part_snippet_with_external_sdk(kde_neon_6_extension_with_build_snap ] } + def test_get_part_snippet_core24(self, kde_neon_6_extension_core24): + self.assert_get_part_snippet(kde_neon_6_extension_core24) -def test_get_part_snippet_with_external_sdk_core24(kde_neon_6_extension_with_build_snap_core24): - assert kde_neon_6_extension_with_build_snap.get_part_snippet( - plugin_name="cmake" - ) == { + +@staticmethod +def assert_get_part_snippet(kde_neon_6_instance): + assert kde_neon_6_instance.get_part_snippet(plugin_name="cmake") == { "build-environment": [ { "PATH": ( @@ -535,14 +672,16 @@ def test_get_part_snippet_with_external_sdk_core24(kde_neon_6_extension_with_bui "/snap/kde-qt6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}:" "/snap/kde-qt6-core24-sdk/current/usr/lib:" "/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}:" - "/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/blas:" - "/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/lapack:" + "/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}" + "/blas:" + "/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}" + "/lapack:" "/snap/kf6-core24-sdk/current/usr/lib:" "$CRAFT_STAGE/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}:" "$CRAFT_STAGE/usr/lib:" "$CRAFT_STAGE/lib/" "${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - ), + ) }, { "CMAKE_PREFIX_PATH": ( @@ -590,14 +729,16 @@ def test_get_parts_snippet(kde_neon_6_extension): } -def test_get_parts_snippet(kde_neon_6_extension_core24): +def test_get_parts_snippet_core24(kde_neon_6_extension_core24): source = get_extensions_data_dir() / "desktop" / "kde-neon-6" - assert kde_neon_6_extension.get_parts_snippet() == { + assert kde_neon_6_extension_core24.get_parts_snippet() == { "kde-neon-6/sdk": { "source": str(source), "plugin": "make", - "make-parameters": ["PLATFORM_PLUG=kf6-core24"], + "make-parameters": [ + "GPU_WRAPPER=gpu-2404-wrapper", + ], "build-snaps": ["kde-qt6-core24-sdk", "kf6-core24-sdk"], "build-packages": [ "gettext", @@ -627,13 +768,15 @@ def test_get_parts_snippet_with_external_sdk(kde_neon_6_extension_with_build_sna def test_get_parts_snippet_with_external_sdk_different_channel( - kde_neon_6_extension_with_default_build_snap_from_latest_edge, + kde_neon_6_extension_with_default_build_snap_from_latest_edge_core24, ): source = get_extensions_data_dir() / "desktop" / "kde-neon-6" - assert kde_neon_6_extension_with_default_build_snap_from_latest_edge.get_parts_snippet() == { + assert kde_neon_6_extension_with_default_build_snap_from_latest_edge_core24.get_parts_snippet() == { "kde-neon-6/sdk": { "source": str(source), "plugin": "make", - "make-parameters": ["PLATFORM_PLUG=kf6-core22"], + "make-parameters": [ + "GPU_WRAPPER=gpu-2404-wrapper", + ], } }