mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-17 20:54:38 +03:00
Add code to validate extensions
This change adds a function that checks for obvious misuses of the `--extension` flag, according to these rules: 1. On Qt6 for Android, an extension for processor architecture is required. 2. On any platform other than Android, or on Qt5, an extension for processor architecture is forbidden. 3. The "wasm" extension only works on desktop targets for Qt 5.13-5.15. This validation function is only called on requests for 'modules' and 'architectures', because these are the only places where the version of Qt is known and the extension matters. Hopefully, this change will reduce confusion among users.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -279,3 +280,44 @@ def test_list_choose_tool_by_version(simple_spec, expected_name):
|
||||
assert item["Name"] == expected_name
|
||||
else:
|
||||
assert expected_name is None
|
||||
|
||||
|
||||
requires_ext_msg = "Qt 6 for Android requires one of the following extensions: "
|
||||
f"{ArchiveId.EXTENSIONS_REQUIRED_ANDROID_QT6}. "
|
||||
"Please add your extension using the `--extension` flag."
|
||||
|
||||
no_arm64_v8_msg = "The extension 'arm64_v8a' is only valid for Qt 6 for Android"
|
||||
no_wasm_msg = "The extension 'wasm' is only available in Qt 5.13 to 5.15 on desktop."
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"target, ext, version, expected_msg",
|
||||
(
|
||||
("android", "", "6.2.0", requires_ext_msg),
|
||||
("android", "arm64_v8a", "5.13.0", no_arm64_v8_msg),
|
||||
("desktop", "arm64_v8a", "5.13.0", no_arm64_v8_msg),
|
||||
("desktop", "arm64_v8a", "6.2.0", no_arm64_v8_msg),
|
||||
("desktop", "wasm", "5.12.11", no_wasm_msg), # out of range
|
||||
("desktop", "wasm", "6.2.0", no_wasm_msg), # out of range
|
||||
("android", "wasm", "5.12.11", no_wasm_msg), # in range, wrong target
|
||||
("android", "wasm", "5.14.0", no_wasm_msg), # in range, wrong target
|
||||
("android", "wasm", "6.2.0", requires_ext_msg), # in range, wrong target
|
||||
),
|
||||
)
|
||||
def test_list_invalid_extensions(
|
||||
capsys, monkeypatch, target, ext, version, expected_msg
|
||||
):
|
||||
def _mock(_, rest_of_url: str) -> str:
|
||||
return ""
|
||||
|
||||
monkeypatch.setattr(ListCommand, "fetch_http", _mock)
|
||||
|
||||
cat = "qt" + version[0]
|
||||
host = "windows"
|
||||
extension_params = ["--extension", ext] if ext else []
|
||||
cli = Cli()
|
||||
cli.run(["list", cat, host, target, *extension_params, "--arch", version])
|
||||
out, err = capsys.readouterr()
|
||||
sys.stdout.write(out)
|
||||
sys.stderr.write(err)
|
||||
assert expected_msg in err
|
||||
|
||||
Reference in New Issue
Block a user