From 11470f923f3b3c8679b87f328d3d53fcc9061e65 Mon Sep 17 00:00:00 2001 From: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com> Date: Mon, 16 Dec 2024 03:21:44 +0100 Subject: [PATCH] Fix tests --- aqt/installer.py | 12 ++++++------ aqt/metadata.py | 19 +++++++++---------- tests/test_list.py | 18 ++++++++++++------ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/aqt/installer.py b/aqt/installer.py index 59e38de3..5a8e3f9b 100644 --- a/aqt/installer.py +++ b/aqt/installer.py @@ -699,12 +699,12 @@ def _set_install_qt_parser(self, install_qt_parser): def _set_install_tool_parser(self, install_tool_parser): install_tool_parser.set_defaults(func=self.run_install_tool) install_tool_parser.add_argument( - "host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name" + "host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name" ) install_tool_parser.add_argument( "target", default=None, - choices=["desktop", "winrt", "android", "ios"], + choices=["desktop", "winrt", "android", "ios", "wasm", "qt"], help="Target SDK.", ) install_tool_parser.add_argument("tool_name", help="Name of tool such as tools_ifw, tools_mingw") @@ -752,7 +752,7 @@ def make_parser_sde(cmd: str, desc: str, action, is_add_kde: bool, is_add_module def make_parser_list_sde(cmd: str, desc: str, cmd_type: str): parser = subparsers.add_parser(cmd, description=desc) parser.add_argument( - "host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name" + "host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name" ) parser.add_argument( "qt_version_spec", @@ -803,7 +803,7 @@ def _make_list_qt_parser(self, subparsers: argparse._SubParsersAction): "target", nargs="?", default=None, - choices=["desktop", "winrt", "android", "ios", "wasm"], + choices=["desktop", "winrt", "android", "ios", "wasm", "qt"], help="Target SDK. When omitted, this prints all the targets available for a host OS.", ) list_parser.add_argument( @@ -883,13 +883,13 @@ def _make_list_tool_parser(self, subparsers: argparse._SubParsersAction): "$ aqt list-tool mac desktop ifw --long # print tool variant names with metadata for QtIFW\n", ) list_parser.add_argument( - "host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name" + "host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name" ) list_parser.add_argument( "target", nargs="?", default=None, - choices=["desktop", "winrt", "android", "ios"], + choices=["desktop", "winrt", "android", "ios", "wasm", "qt"], help="Target SDK. When omitted, this prints all the targets available for a host OS.", ) list_parser.add_argument( diff --git a/aqt/metadata.py b/aqt/metadata.py index b43692f8..b79c182d 100644 --- a/aqt/metadata.py +++ b/aqt/metadata.py @@ -214,8 +214,8 @@ class ArchiveId: "wasm", "src_doc_examples", *EXTENSIONS_REQUIRED_ANDROID_QT6, - "wasm_singlethread", - "wasm_multithread", + # "wasm_singlethread", + # "wasm_multithread", } def __init__(self, category: str, host: str, target: str): @@ -289,14 +289,13 @@ def to_folder(self, version: Version, qt_version_no_dots: str, extension: Option if extension: return f"qt{version.major}_{qt_version_no_dots}_{extension}" return f"qt{version.major}_{qt_version_no_dots}" - else: - # Pre-6.8 structure for non-WASM or pre-6.5 structure - return "{category}{major}_{ver}{ext}".format( - category=self.category, - major=qt_version_no_dots[0], - ver=qt_version_no_dots, - ext="_" + extension if extension else "", - ) + # Pre-6.8 structure for non-WASM or pre-6.5 structure + return "{category}{major}_{ver}{ext}".format( + category=self.category, + major=qt_version_no_dots[0], + ver=qt_version_no_dots, + ext="_" + extension if extension else "", + ) def all_extensions(self, version: Version) -> List[str]: if self.target == "desktop" and QtRepoProperty.is_in_wasm_range(self.host, version): diff --git a/tests/test_list.py b/tests/test_list.py index ffac6f19..3dae4724 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -443,15 +443,22 @@ def expected_windows_desktop_plus_wasm_5140(is_wasm_threaded: bool) -> Dict: ) def test_list_wasm_arches(monkeypatch, capsys, host: str, target: str, version: str, arch: str, expect_arches: Set[str]): def _mock_fetch_http(_, rest_of_url: str, *args, **kwargs) -> str: - if rest_of_url.endswith("Updates.xml"): + + if rest_of_url.endswith("wasm_singlethread/Updates.xml"): + if version >= "6.8.0": + return (Path(__file__).parent / "data" / "all_os-680-wasm-single-update.xml").read_text("utf-8") + else: + return (Path(__file__).parent / "data" / "all_os-673-wasm-single-update.xml").read_text("utf-8") + elif rest_of_url.endswith("wasm_multithread/Updates.xml"): if version >= "6.8.0": - return (Path(__file__).parent / "data" / "windows-680-wasm-single-update.xml").read_text("utf-8") + return (Path(__file__).parent / "data" / "all_os-680-wasm-multi-update.xml").read_text("utf-8") else: - return (Path(__file__).parent / "data" / "windows-673-wasm-single-update.xml").read_text("utf-8") + return (Path(__file__).parent / "data" / "all_os-673-wasm-multi-update.xml").read_text("utf-8") return "" # Return empty HTML since we don't need it monkeypatch.setattr("aqt.metadata.getUrl", _mock_fetch_http) - monkeypatch.setattr("aqt.metadata.MetadataFactory.fetch_http", _mock_fetch_http) + # monkeypatch.setattr("aqt.metadata.fetch_http", _mock_fetch_http) + monkeypatch.setattr(MetadataFactory, "fetch_http", _mock_fetch_http) cli = Cli() cli._setup_settings() @@ -472,7 +479,6 @@ def _mock_fetch_http(_, rest_of_url: str, *args, **kwargs) -> str: ("--modules 5.14.0 win64_msvc2017_64", False, ["modules_by_arch", "win64_msvc2017_64"]), ("--modules 6.5.0 wasm_singlethread", True, ["modules_by_arch", "wasm_singlethread"]), ("--modules 6.5.0 wasm_multithread", True, ["modules_by_arch", "wasm_multithread"]), - ("--arch latest", True, ["architectures"]), ("--spec 5.14 --arch latest", False, ["architectures"]), ("--arch 5.14.0", False, ["architectures"]), ), @@ -529,7 +535,7 @@ def get_xml_filename() -> str: assert output_set == expect_set -def test_list_missing_wasm_updates(monkeypatch, capsys): +def test_list_missing_wasm_updates_for_windows(monkeypatch, capsys): """Require that MetadataFactory is resilient to missing wasm updates.xml files""" data_dir = Path(__file__).parent / "data" expect = set(json.loads((data_dir / "windows-620-expect.json").read_text("utf-8"))["architectures"])