Merge remote-tracking branch 'upstream/master' into add-list-qt-archives

This commit is contained in:
David Dalcino
2021-09-20 17:53:13 -07:00
12 changed files with 345 additions and 169 deletions

View File

@@ -437,8 +437,12 @@ class Cli:
return
if args.target not in ArchiveId.TARGETS_FOR_HOST[args.host]:
raise CliInputError("'{0.target}' is not a valid target for host '{0.host}'".format(args))
if args.modules:
modules_ver, modules_query = args.modules[0], tuple(args.modules)
else:
modules_ver, modules_query = None, None
for version_str in (args.modules, args.extensions, args.arch, args.archives[0] if args.archives else None):
for version_str in (modules_ver, args.extensions, args.arch, args.archives[0] if args.archives else None):
Cli._validate_version_str(version_str, allow_latest=True, allow_empty=True)
spec = None
@@ -457,7 +461,7 @@ class Cli:
),
spec=spec,
is_latest_version=args.latest_version,
modules_ver=args.modules,
modules_query=modules_query,
extensions_ver=args.extensions,
architectures_ver=args.arch,
archives_query=args.archives,
@@ -603,7 +607,7 @@ class Cli:
"$ aqt list-qt mac desktop --extension wasm # print all wasm versions of Qt 5\n"
'$ aqt list-qt mac desktop --spec "5.9" # print all versions of Qt 5.9\n'
'$ aqt list-qt mac desktop --spec "5.9" --latest-version # print latest Qt 5.9\n'
"$ aqt list-qt mac desktop --modules 5.12.0 # print modules for 5.12.0\n"
"$ aqt list-qt mac desktop --modules 5.12.0 clang_64 # print modules for 5.12.0\n"
"$ aqt list-qt mac desktop --spec 5.9 --modules latest # print modules for latest 5.9\n"
"$ aqt list-qt mac desktop --extensions 5.9.0 # print choices for --extension flag\n"
"$ aqt list-qt mac desktop --arch 5.9.9 "
@@ -638,8 +642,10 @@ class Cli:
output_modifier_exclusive_group.add_argument(
"--modules",
type=str,
metavar="(VERSION | latest)",
help='Qt version in the format of "5.X.Y", or the keyword "latest". '
nargs=2,
metavar=("(VERSION | latest)", "ARCHITECTURE"),
help='First arg: Qt version in the format of "5.X.Y", or the keyword "latest". '
'Second arg: an architecture, which may be printed with the "--arch" flag. '
"When set, this prints all the modules available for either Qt 5.X.Y or the latest version of Qt.",
)
output_modifier_exclusive_group.add_argument(

View File

@@ -362,7 +362,7 @@ class MetadataFactory:
*,
spec: Optional[SimpleSpec] = None,
is_latest_version: bool = False,
modules_ver: Optional[str] = None,
modules_query: Optional[Tuple[str, str]] = None,
extensions_ver: Optional[str] = None,
architectures_ver: Optional[str] = None,
archives_query: Optional[List[str]] = None,
@@ -376,7 +376,7 @@ class MetadataFactory:
Qt that don't fit this SimpleSpec.
:param is_latest_version: When True, the MetadataFactory will find all versions of Qt
matching filters, and only print the most recent version
:param modules_ver: Version of Qt for which to list modules
:param modules_query: [Version of Qt, architecture] for which to list modules
:param extensions_ver: Version of Qt for which to list extensions
:param architectures_ver: Version of Qt for which to list architectures
:param archives_query: [Qt_Version, architecture, *module_names]: used to print list of archives
@@ -403,9 +403,10 @@ class MetadataFactory:
elif is_latest_version:
self.request_type = "latest version"
self._action = lambda: Versions(self.fetch_latest_version())
elif modules_ver:
elif modules_query:
self.request_type = "modules"
self._action = lambda: self.fetch_modules(self._to_version(modules_ver))
version, arch = modules_query
self._action = lambda: self.fetch_modules(self._to_version(version), arch)
elif extensions_ver:
self.request_type = "extensions"
self._action = lambda: self.fetch_extensions(self._to_version(extensions_ver))
@@ -425,11 +426,20 @@ class MetadataFactory:
def getList(self) -> Union[List[str], Versions, ToolData]:
return self._action()
def fetch_modules(self, version: Version) -> List[str]:
return self.get_modules_architectures_for_version(version=version)[0]
def fetch_arches(self, version: Version) -> List[str]:
return self.get_modules_architectures_for_version(version=version)[1]
self.validate_extension(version)
if self.archive_id.extension == "src_doc_examples":
return []
qt_ver_str = self._get_qt_version_str(version)
modules = self._fetch_module_metadata(self.archive_id.to_folder(qt_ver_str))
arches = []
for name in modules.keys():
ver, arch = name.split(".")[-2:]
if ver == qt_ver_str:
arches.append(arch)
return arches
def fetch_extensions(self, version: Version) -> List[str]:
versions_extensions = MetadataFactory.get_versions_extensions(
@@ -623,12 +633,13 @@ class MetadataFactory:
predicate=predicate if predicate else MetadataFactory._has_nonempty_downloads,
)
def get_modules_architectures_for_version(self, version: Version) -> Tuple[List[str], List[str]]:
"""Returns [list of modules, list of architectures]"""
def fetch_modules(self, version: Version, arch: str) -> List[str]:
"""Returns list of modules"""
self.validate_extension(version)
qt_ver_str = self._get_qt_version_str(version)
# Example: re.compile(r"^(preview\.)?qt\.(qt5\.)?590\.(.+)$")
pattern = re.compile(r"^(preview\.)?qt\.(qt" + str(version.major) + r"\.)?" + qt_ver_str + r"\.(.+)$")
modules_meta = self._fetch_module_metadata(self.archive_id.to_folder(qt_ver_str))
def to_module_arch(name: str) -> Tuple[Optional[str], Optional[str]]:
_match = pattern.match(name)
@@ -642,28 +653,12 @@ class MetadataFactory:
module = module[len("addons.") :]
return module, arch
modules = self._fetch_module_metadata(self.archive_id.to_folder(qt_ver_str))
def naive_modules_arches(
names: Iterable[str],
) -> Tuple[List[str], List[str]]:
modules_and_arches, _modules, arches = set(), set(), set()
for name in names:
# First term could be a module name or an architecture
first_term, arch = to_module_arch(name)
if first_term:
modules_and_arches.add(first_term)
if arch:
arches.add(arch)
for first_term in modules_and_arches:
if first_term not in arches:
_modules.add(first_term)
return (
sorted(_modules),
sorted(arches),
)
return naive_modules_arches(modules.keys())
modules = set()
for name in modules_meta.keys():
module, _arch = to_module_arch(name)
if _arch == arch:
modules.add(module)
return sorted(modules)
def fetch_archives(self, version: Version, arch: str, modules: List[str]) -> List[str]:
qt_version_str = self._get_qt_version_str(version)
@@ -725,10 +720,13 @@ def suggested_follow_up(meta: MetadataFactory) -> List[str]:
)
elif meta.request_type in ("architectures", "modules", "extensions"):
msg.append(f"Please use '{base_cmd}' to show versions of Qt available.")
if meta.request_type == "modules":
msg.append(f"Please use '{base_cmd} --arch <QT_VERSION>' to list valid architectures.")
elif meta.request_type == "archives for modules":
msg.extend([versions_msg, arches_msg, f"Please use '{base_cmd} --modules <QT_VERSION>' to show modules available."])
elif meta.request_type == "archives for qt":
msg.extend([versions_msg, arches_msg])
return msg

View File

@@ -192,16 +192,16 @@ linux_build_jobs.extend(
"install-doc", "6.1.0", "linux", "desktop", "gcc_64", "gcc_64", subarchives="qtdoc"
),
# test for list commands
BuildJob('list', '5.15.2', 'linux', 'desktop', '', '', spec="<6", list_options={
BuildJob('list', '5.15.2', 'linux', 'desktop', 'gcc_64', '', spec="<6", list_options={
'HAS_EXTENSIONS': "True",
}),
BuildJob('list', '6.1.0', 'linux', 'android', '', '', spec=">6.0,<6.1.1", list_options={
BuildJob('list', '6.1.0', 'linux', 'android', 'android_armv7', '', spec=">6.0,<6.1.1", list_options={
'HAS_EXTENSIONS': "True",
'USE_EXTENSION': "armv7",
}),
# tests run on linux but query data about other platforms
BuildJob('list', '5.14.1', 'mac', 'ios', '', '', spec="<=5.14.1", list_options={}),
BuildJob('list', '5.13.1', 'windows', 'winrt', '', '', spec=">5.13.0,<5.13.2", list_options={}),
BuildJob('list', '5.14.1', 'mac', 'ios', 'ios', '', spec="<=5.14.1", list_options={}),
BuildJob('list', '5.13.1', 'windows', 'winrt', 'win64_msvc2015_winrt_x64', '', spec=">5.13.0,<5.13.2", list_options={}),
]
)
mac_build_jobs.extend(

View File

@@ -100,14 +100,14 @@ def iter_qt_minor_groups(
def iter_modules_for_qt_minor_groups(
host: str = "linux", target: str = "desktop"
host: str = "linux", target: str = "desktop", arch: str = "gcc_64"
) -> Generator[Dict, None, None]:
logger.info("Fetching qt modules for {}/{}".format(host, target))
for major, minor in tqdm(list(iter_qt_minor_groups(host, target))):
yield {
"qt_version": f"{major}.{minor}",
"modules": MetadataFactory(
ArchiveId("qt", host, target), modules_ver=f"{major}.{minor}.0"
ArchiveId("qt", host, target), modules_query=(f"{major}.{minor}.0", arch)
).getList(),
}

View File

@@ -90,8 +90,8 @@ steps:
aqt list-qt $(HOST) $(TARGET) $ext --spec "$(SPEC)" # print all versions of Qt in SimpleSpec
ver=$(aqt list-qt $(HOST) $(TARGET) $ext --spec "$(SPEC)" --latest-version) # latest Qt in SimpleSpec
[ $ver == $(QT_VERSION) ] # latest version in SPEC must be QT_VERSION
aqt list-qt $(HOST) $(TARGET) $ext --spec "$(SPEC)" --modules latest # print modules for latest in SimpleSpec
aqt list-qt $(HOST) $(TARGET) $ext --modules $(QT_VERSION) # print modules for version/host/target
aqt list-qt $(HOST) $(TARGET) $ext --spec "$(SPEC)" --modules latest $(ARCH) # print modules for latest in SimpleSpec
aqt list-qt $(HOST) $(TARGET) $ext --modules $(QT_VERSION) $(ARCH) # print modules for version/host/target/arch
if [[ $(HAS_EXTENSIONS) == "True" ]]; then
aqt list-qt $(HOST) $(TARGET) --extensions $(QT_VERSION) # print choices for --extension flag
aqt list-qt $(HOST) $(TARGET) --spec "$(SPEC)" --extensions latest

View File

@@ -43,7 +43,7 @@ list-qt command
aqt list-qt [-h | --help]
[--extension <extension>]
[--spec <specification>]
[--modules (<Qt version> | latest) |
[--modules (<Qt version> | latest) <architecture> |
--extensions (<Qt version> | latest) |
--arch (<Qt version> | latest) |
--archives (<Qt version> | latest) architecture [modules...]
@@ -94,11 +94,12 @@ List available versions of Qt, targets, extensions, modules, and architectures.
.. _SimpleSpec: https://python-semanticversion.readthedocs.io/en/latest/reference.html#semantic_version.SimpleSpec
.. option:: --modules (<Qt version> | latest)
.. option:: --modules (<Qt version> | latest) <architecture>
Qt version in the format of "5.X.Y". When set, this lists all the modules
available for Qt 5.X.Y with a host/target/extension, or the latest version
of Qt if ``latest`` is specified.
This flag lists all the modules available for Qt 5.X.Y with a host/target/extension/architecture
combination, or the latest version of Qt if ``latest`` is specified.
You can list available architectures by using ``aqt list-qt`` with the
``--arch`` flag described below.
.. option:: --arch (<Qt version> | latest)
@@ -177,7 +178,7 @@ List available tools
.. code-block:: console
$ python -m aqt list-tool windows desktop tools_conan
$ python -m aqt list-tool windows desktop tools_conan -l
Tool Variant Name Version Release Date Display Name Description
============================================================================================================
@@ -615,7 +616,7 @@ Example: List available modules for latest version of Qt on macOS
.. code-block:: console
aqt list-qt mac desktop --modules latest # prints 'qtquick3d qtshadertools', etc
aqt list-qt mac desktop --modules latest clang_64 # prints 'qtquick3d qtshadertools', etc
Example: List available architectures for Qt 6.1.2 on windows

View File

@@ -151,13 +151,13 @@ Installing Modules
Let's say we need to install some modules for Qt 5.15.2 on Windows Desktop.
First we need to find out what the modules are called, and we can do that
with :ref:`aqt list-qt <list qt command>` with the ``--modules`` flag.
Each version of Qt has a different list of modules for each host OS/ target SDK
Each version of Qt has a different list of modules for each host OS/ target SDK/ architecture
combination, so we will need to supply :ref:`aqt list-qt <list qt command>` with that information:
.. code-block:: console
$ aqt list-qt windows desktop --modules 5.15.2
debug_info qtcharts qtdatavis3d qtlottie qtnetworkauth qtpurchasing qtquick3d
$ aqt list-qt windows desktop --modules 5.15.2 win64_mingw81
qtcharts qtdatavis3d qtlottie qtnetworkauth qtpurchasing qtquick3d
qtquicktimeline qtscript qtvirtualkeyboard qtwebengine qtwebglplugin
Let's say that we want to install `qtcharts` and `qtnetworkauth`.
@@ -181,7 +181,7 @@ One way to install all modules available for Qt 5.15.2 is to send the output of
.. code-block:: console
$ aqt install-qt windows desktop 5.15.2 win64_mingw81 \
-m $(aqt list-qt windows desktop --modules 5.15.2)
-m $(aqt list-qt windows desktop --modules 5.15.2 win64_mingw81)
You will need a Unix-style shell to run this command, or at least git-bash on Windows.
The ``xargs`` equivalent to this command is an exercise left to the reader.
@@ -211,7 +211,7 @@ for Desktop on Windows, but there will be differences when we get to Qt 6.
$ aqt list-qt windows android --arch 5.15.2 # Print architectures available
android
$ aqt list-qt windows android --modules 5.15.2 # Print modules available
$ aqt list-qt windows android --modules 5.15.2 android # Print modules available
qtcharts qtdatavis3d qtlottie qtnetworkauth qtpurchasing qtquick3d qtquicktimeline qtscript
$ aqt install-qt windows android 5.15.2 android -m qtcharts qtnetworkauth # Install
@@ -225,7 +225,7 @@ Let's see what happens when we try to list architectures and modules for Qt 6:
('x86_64', 'x86', 'armv7', 'arm64_v8a').
Please add your extension using the `--extension` flag.
$ aqt list-qt windows android --modules 6.2.0 # Print modules available
$ aqt list-qt windows android --modules 6.2.0 android_armv7 # Print modules available
Command line input error: Qt 6 for Android requires one of the following extensions:
('x86_64', 'x86', 'armv7', 'arm64_v8a').
Please add your extension using the `--extension` flag.
@@ -237,19 +237,10 @@ backwards, but that's how the Qt repo was put together.
There are four architectures available, and the error message from :ref:`aqt list-qt <list qt command>`
just told us what they are: `x86_64`, `x86`, `armv7`, and `arm64_v8a`.
If we want to install Qt 6.2.0 for armv7, we use this command to print available modules:
.. code-block:: console
$ aqt list-qt windows android --extension armv7 --modules 6.2.0
qt3d qt5compat qtcharts qtconnectivity qtdatavis3d qtimageformats qtlottie
qtmultimedia qtnetworkauth qtpositioning qtquick3d qtquicktimeline
qtremoteobjects qtscxml qtsensors qtserialbus qtserialport qtshadertools
qtvirtualkeyboard qtwebchannel qtwebsockets qtwebview
We know we want to use `armv7` for the architecture, but we don't know exactly
what value for 'architecture' we need to pass to :ref:`aqt install-qt <qt installation command>` yet, so we
will use :ref:`aqt list-qt <list qt command>` again:
what value for 'architecture' we need to pass to :ref:`aqt install-qt <qt installation command>`
yet, so we will use :ref:`aqt list-qt <list qt command>` again:
.. code-block:: console
@@ -264,7 +255,18 @@ message, instead of the obvious `android_armv7`, we would know that Qt 6.2.0
for that architecture doesn't exist for some reason, and any attempt to install
it with :ref:`aqt install-qt <qt installation command>` will fail.
Finally, let's install Qt 6.2.0 for Android armv7 with some modules:
If we want to install Qt 6.2.0 for armv7, we use this command to print available modules:
.. code-block:: console
$ aqt list-qt windows android --extension armv7 --modules 6.2.0 android_armv7
qt3d qt5compat qtcharts qtconnectivity qtdatavis3d qtimageformats qtlottie
qtmultimedia qtnetworkauth qtpositioning qtquick3d qtquicktimeline
qtremoteobjects qtscxml qtsensors qtserialbus qtserialport qtshadertools
qtvirtualkeyboard qtwebchannel qtwebsockets qtwebview
Finally, let's install Qt 6.2.0 for Android armv7 with the ``qtcharts`` and
``qtnetworkauth`` modules:
.. code-block:: console
@@ -292,10 +294,10 @@ We can check the architecture and modules available as before:
.. code-block:: console
$ aqt list-qt windows desktop --extension wasm --arch 5.15.2 # Print architectures available
$ aqt list-qt windows desktop --extension wasm --arch 5.15.2 # available architectures
wasm_32
$ aqt list-qt windows desktop --extension wasm --modules 5.15.2 # Print modules available
$ aqt list-qt windows desktop --extension wasm --modules 5.15.2 wasm_32 # available modules
qtcharts qtdatavis3d qtlottie qtnetworkauth qtpurchasing qtquicktimeline qtscript
qtvirtualkeyboard qtwebglplugin

View File

@@ -1,5 +1,25 @@
{
"modules": [
"architectures": [
"win32_mingw73",
"win32_msvc2017",
"win64_mingw73",
"win64_msvc2015_64",
"win64_msvc2017_64"
],
"modules_by_arch": {
"win32_mingw73": [
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebglplugin"
],
"win32_msvc2017": [
"debug_info",
"qtcharts",
"qtdatavis3d",
@@ -13,13 +33,46 @@
"qtwebengine",
"qtwebglplugin"
],
"architectures": [
"win32_mingw73",
"win32_msvc2017",
"win64_mingw73",
"win64_msvc2015_64",
"win64_msvc2017_64"
"win64_mingw73": [
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebglplugin"
],
"win64_msvc2015_64": [
"debug_info",
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebglplugin"
],
"win64_msvc2017_64": [
"debug_info",
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebengine",
"qtwebglplugin"
]
},
"modules_metadata_by_arch": {
"win32_mingw73": [
{

View File

@@ -1,5 +1,25 @@
{
"modules": [
"architectures": [
"win32_mingw81",
"win32_msvc2019",
"win64_mingw81",
"win64_msvc2015_64",
"win64_msvc2019_64"
],
"modules_by_arch": {
"win32_mingw81": [
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebglplugin"
],
"win32_msvc2019": [
"debug_info",
"qtcharts",
"qtdatavis3d",
@@ -13,11 +33,44 @@
"qtwebengine",
"qtwebglplugin"
],
"architectures": [
"win32_mingw81",
"win32_msvc2019",
"win64_mingw81",
"win64_msvc2015_64",
"win64_msvc2019_64"
"win64_mingw81": [
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebglplugin"
],
"win64_msvc2015_64": [
"debug_info",
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebglplugin"
],
"win64_msvc2019_64": [
"debug_info",
"qtcharts",
"qtdatavis3d",
"qtlottie",
"qtnetworkauth",
"qtpurchasing",
"qtquick3d",
"qtquicktimeline",
"qtscript",
"qtvirtualkeyboard",
"qtwebengine",
"qtwebglplugin"
]
}
}

View File

@@ -1,8 +1,38 @@
{
"modules": [
"debug_info",
"architectures": [
"win64_mingw81",
"win64_msvc2019_64",
"win64_msvc2019_arm64"
],
"modules_by_arch": {
"win64_mingw81": [
"qt3d",
"qtactiveqt",
"qtcharts",
"qtconnectivity",
"qtdatavis3d",
"qtimageformats",
"qtlottie",
"qtmultimedia",
"qtnetworkauth",
"qtpositioning",
"qtremoteobjects",
"qtscxml",
"qtsensors",
"qtserialbus",
"qtserialport",
"qtvirtualkeyboard",
"qtwebchannel",
"qtwebsockets",
"qtwebview",
"debug_info",
"qt5compat",
"qtquick3d",
"qtquicktimeline",
"qtshadertools"
],
"win64_msvc2019_64": [
"qt3d",
"qt5compat",
"qtactiveqt",
"qtcharts",
"qtconnectivity",
@@ -12,23 +42,44 @@
"qtmultimedia",
"qtnetworkauth",
"qtpositioning",
"qtquick3d",
"qtquicktimeline",
"qtremoteobjects",
"qtscxml",
"qtsensors",
"qtserialbus",
"qtserialport",
"qtshadertools",
"qtvirtualkeyboard",
"qtwebchannel",
"qtwebengine",
"qtwebsockets",
"qtwebview"
"qtwebview",
"debug_info",
"qt5compat",
"qtquick3d",
"qtquicktimeline",
"qtshadertools"
],
"architectures": [
"win64_mingw81",
"win64_msvc2019_64",
"win64_msvc2019_arm64"
"win64_msvc2019_arm64": [
"qt3d",
"qtactiveqt",
"qtcharts",
"qtdatavis3d",
"qtimageformats",
"qtlottie",
"qtnetworkauth",
"qtpositioning",
"qtremoteobjects",
"qtscxml",
"qtsensors",
"qtserialbus",
"qtserialport",
"qtvirtualkeyboard",
"qtwebchannel",
"qtwebsockets",
"debug_info",
"qt5compat",
"qtquick3d",
"qtquicktimeline",
"qtshadertools"
]
}
}

View File

@@ -133,7 +133,7 @@ def test_cli_invalid_version(capsys, invalid_version):
for cmd in (
("install", invalid_version, "mac", "desktop"),
("doc", invalid_version, "mac", "desktop"),
("list-qt", "mac", "desktop", "--modules", invalid_version),
("list-qt", "mac", "desktop", "--arch", invalid_version),
):
cli = Cli()
assert cli.run(cmd) == 1

View File

@@ -198,8 +198,9 @@ def test_list_architectures_and_modules(monkeypatch, version: str, extension: st
monkeypatch.setattr(MetadataFactory, "fetch_http", lambda self, _: _xml)
modules = MetadataFactory(archive_id).fetch_modules(Version(version))
assert modules == expect["modules"]
for arch in expect["architectures"]:
modules = MetadataFactory(archive_id).fetch_modules(Version(version), arch)
assert modules == sorted(expect["modules_by_arch"][arch])
arches = MetadataFactory(archive_id).fetch_arches(Version(version))
assert arches == expect["architectures"]
@@ -306,10 +307,9 @@ def test_tool_modules(monkeypatch, host: str, target: str, tool_name: str):
@pytest.fixture
def expected_windows_desktop_5140() -> Dict[str, Set[str]]:
def expected_windows_desktop_5140() -> Dict:
xmlexpect = "windows-5140-expect.json"
expected_modules_arches = json.loads((Path(__file__).parent / "data" / xmlexpect).read_text("utf-8"))
return {key: set(val) for key, val in expected_modules_arches.items()}
return json.loads((Path(__file__).parent / "data" / xmlexpect).read_text("utf-8"))
@pytest.mark.parametrize(
@@ -318,18 +318,22 @@ def expected_windows_desktop_5140() -> Dict[str, Set[str]]:
("--extensions latest", {"src_doc_examples"}),
("--spec 5.14 --extensions latest", {"wasm", "src_doc_examples"}),
("--extensions 5.14.0", {"wasm", "src_doc_examples"}),
("--modules latest", "modules"),
("--spec 5.14 --modules latest", "modules"),
("--modules 5.14.0", "modules"),
("--extension wasm --modules latest", "modules"),
("--extension wasm --spec 5.14 --modules latest", "modules"),
("--extension wasm --modules 5.14.0", "modules"),
("--arch latest", "architectures"),
("--spec 5.14 --arch latest", "architectures"),
("--arch 5.14.0", "architectures"),
("--extension wasm --arch latest", "architectures"),
("--extension wasm --spec 5.14 --arch latest", "architectures"),
("--extension wasm --arch 5.14.0", "architectures"),
("--modules latest win64_msvc2017_64", ["modules_by_arch", "win64_msvc2017_64"]),
("--spec 5.14 --modules latest win64_msvc2017_64", ["modules_by_arch", "win64_msvc2017_64"]),
("--modules 5.14.0 win32_mingw73", ["modules_by_arch", "win32_mingw73"]),
("--modules 5.14.0 win32_msvc2017", ["modules_by_arch", "win32_msvc2017"]),
("--modules 5.14.0 win64_mingw73", ["modules_by_arch", "win64_mingw73"]),
("--modules 5.14.0 win64_msvc2015_64", ["modules_by_arch", "win64_msvc2015_64"]),
("--modules 5.14.0 win64_msvc2017_64", ["modules_by_arch", "win64_msvc2017_64"]),
("--extension wasm --modules latest win64_msvc2017_64", ["modules_by_arch", "win64_msvc2017_64"]),
("--extension wasm --spec 5.14 --modules latest win64_msvc2017_64", ["modules_by_arch", "win64_msvc2017_64"]),
("--extension wasm --modules 5.14.0 win64_msvc2017_64", ["modules_by_arch", "win64_msvc2017_64"]),
("--arch latest", ["architectures"]),
("--spec 5.14 --arch latest", ["architectures"]),
("--arch 5.14.0", ["architectures"]),
("--extension wasm --arch latest", ["architectures"]),
("--extension wasm --spec 5.14 --arch latest", ["architectures"]),
("--extension wasm --arch 5.14.0", ["architectures"]),
),
)
def test_list_qt_cli(
@@ -337,10 +341,20 @@ def test_list_qt_cli(
capsys,
expected_windows_desktop_5140: Dict[str, Set[str]],
args: str,
expect: Union[Set[str], str],
expect: Union[Set[str], List[str]],
):
htmlfile, xmlfile = "windows-desktop.html", "windows-5140-update.xml"
version_string_to_replace = "qt5.5140"
if isinstance(expect, list):
# In this case, 'expect' is a list of keys to follow to the expected values.
expected_dict = expected_windows_desktop_5140
for key in expect: # Follow the chain of keys to the list of values.
expected_dict = expected_dict[key]
assert isinstance(expected_dict, list)
expect_set = set(expected_dict)
else:
expect_set = expect
assert isinstance(expect_set, set)
def _mock_fetch_http(_, rest_of_url: str) -> str:
htmltext = (Path(__file__).parent / "data" / htmlfile).read_text("utf-8")
@@ -362,7 +376,6 @@ def test_list_qt_cli(
cli.run(["list-qt", "windows", "desktop", *args.split()])
out, err = capsys.readouterr()
output_set = set(out.strip().split())
expect_set = expected_windows_desktop_5140[expect] if isinstance(expect, str) else expect
assert output_set == expect_set
@@ -489,11 +502,10 @@ def test_list_invalid_extensions(capsys, monkeypatch, target, ext, version, expe
mac_qt = ArchiveId("qt", "mac", "desktop")
mac_wasm = ArchiveId("qt", "mac", "desktop", "wasm")
wrong_qt_version_msg = ["Please use 'aqt list-qt mac desktop' to show versions of Qt available."]
wrong_ext_and_version_msg = [
"Please use 'aqt list-qt mac desktop --extensions <QT_VERSION>' to list valid extensions.",
"Please use 'aqt list-qt mac desktop' to show versions of Qt available.",
]
wrong_tool_name_msg = "Please use 'aqt list-tool mac desktop' to check what tools are available."
wrong_qt_version_msg = "Please use 'aqt list-qt mac desktop' to show versions of Qt available."
wrong_ext_msg = "Please use 'aqt list-qt mac desktop --extensions <QT_VERSION>' to list valid extensions."
wrong_arch_msg = "Please use 'aqt list-qt mac desktop --arch <QT_VERSION>' to list valid architectures."
@pytest.mark.parametrize(
@@ -506,19 +518,19 @@ wrong_ext_and_version_msg = [
),
(
MetadataFactory(ArchiveId("tools", "mac", "desktop"), tool_name="ifw"),
["Please use 'aqt list-tool mac desktop' to check what tools are available."],
[wrong_tool_name_msg],
),
(
MetadataFactory(mac_qt, architectures_ver="1.2.3"),
wrong_qt_version_msg,
[wrong_qt_version_msg],
),
(
MetadataFactory(mac_qt, modules_ver="1.2.3"),
wrong_qt_version_msg,
MetadataFactory(mac_qt, modules_query=("1.2.3", "clang_64")),
[wrong_qt_version_msg, wrong_arch_msg],
),
(
MetadataFactory(mac_qt, extensions_ver="1.2.3"),
wrong_qt_version_msg,
[wrong_qt_version_msg],
),
(
MetadataFactory(mac_qt, archives_query=["1.2.3", "clang_64", "a module", "another module"]),
@@ -537,12 +549,12 @@ wrong_ext_and_version_msg = [
),
(
MetadataFactory(mac_wasm),
["Please use 'aqt list-qt mac desktop --extensions <QT_VERSION>' to list valid extensions."],
[wrong_ext_msg],
),
(
MetadataFactory(mac_wasm, spec=SimpleSpec("<5.9")),
[
"Please use 'aqt list-qt mac desktop --extensions <QT_VERSION>' to list valid extensions.",
wrong_ext_msg,
"Please use 'aqt list-qt mac desktop' to check that versions of qt exist within the spec '<5.9'.",
],
),
@@ -550,20 +562,20 @@ wrong_ext_and_version_msg = [
MetadataFactory(ArchiveId("tools", "mac", "desktop", "wasm"), tool_name="ifw"),
[
"Please use 'aqt list-tool mac desktop --extensions <QT_VERSION>' to list valid extensions.",
"Please use 'aqt list-tool mac desktop' to check what tools are available.",
wrong_tool_name_msg,
],
),
(
MetadataFactory(mac_wasm, architectures_ver="1.2.3"),
wrong_ext_and_version_msg,
[wrong_ext_msg, wrong_qt_version_msg],
),
(
MetadataFactory(mac_wasm, modules_ver="1.2.3"),
wrong_ext_and_version_msg,
MetadataFactory(mac_wasm, modules_query=("1.2.3", "clang_64")),
[wrong_ext_msg, wrong_qt_version_msg, wrong_arch_msg],
),
(
MetadataFactory(mac_wasm, extensions_ver="1.2.3"),
wrong_ext_and_version_msg,
[wrong_ext_msg, wrong_qt_version_msg],
),
),
)