Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidev committed Dec 16, 2024
1 parent cacabe8 commit 11470f9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
12 changes: 6 additions & 6 deletions aqt/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
19 changes: 9 additions & 10 deletions aqt/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
18 changes: 12 additions & 6 deletions tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"]),
),
Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit 11470f9

Please sign in to comment.