Commit Graph

64 Commits

Author SHA1 Message Date
Dave Dalcino
112080e6cb black 2023-08-28 05:28:46 -07:00
Dave Dalcino
772c20aa4d Remove duplicated test 2023-08-28 05:28:45 -07:00
Dave Dalcino
85037194fe Remove fallback parameter 2023-08-28 05:28:45 -07:00
Dave Dalcino
9752164811 Add test for refactored _set_sevenzip 2023-08-28 05:28:45 -07:00
Dave Dalcino
9b102de2b4 Test Cli._select_unexpected_modules for missing qt
This adds coverage for the situation where there is no known list of
modules, since the Qt version is unknown.
2023-02-16 14:53:56 -08:00
Dave Dalcino
6a0c174e01 Improve warning messages re: unknown aqt arguments
This improves the warnings about unknown versions, modules, and
architectures of Qt, so that it is more explicit what the message
actually means.

This changes the purpose of `Cli._check_modules_arg` from checking if
modules exist in combinations.json, to returning a list of modules
that do not exist in that file. The function has been renamed as well.
This change was necessary to make the warning message more informative.
2023-02-16 14:01:39 -08:00
Dave Dalcino
e3c7d14c3f Add tests for qt 6.5.0 wasm 2023-02-11 10:35:48 -08:00
iakov
77910835c2 Make black happy with new formatting for tests 2023-02-03 20:12:01 +03:00
Dave Dalcino
c90b262984 remove extensions from ArchiveId 2022-11-16 16:14:55 -08:00
Dave Dalcino
caee04bcb3 Remove extensions 2022-11-16 16:14:54 -08:00
Dave Dalcino
d73c89a89f fix expected error message in test cases 2022-11-14 19:23:44 -08:00
Dave Dalcino
f63e0d9a64 Fix test_get_autodesktop_dir_and_arch for Windows 2022-08-20 09:56:40 -07:00
Dave Dalcino
bcd4e03838 Refactor test_install to mock multiple Qts
This will allow testing multiple qt installations, as required by the
feature that installs the default desktop qt where required

Add autodesktop test for ios
2022-08-20 09:09:36 -07:00
Dave Dalcino
703f2d2fe3 rework logic for readability 2022-08-20 09:09:23 -07:00
Dave Dalcino
78fe5f30eb Improve unit test coverage 2022-08-20 09:04:40 -07:00
Mozi
60889b7296 Log: left align the level name with padding (#539)
* Change log format for brief

- prepend %(levelname)s:

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Update test expectations for error/warning messages

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* log: left align the level name with padding

Why 8: sizeof("CRITICAL") == 8

Ref:
  printf-style String Formatting § Built-in Types — Python 3 documentation
  https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting

* log: remove the duplicate "warning" words

Co-authored-by: Hiroshi Miura <miurahr@linux.com>
2022-07-18 22:29:16 +09:00
David Dalcino
b62db9ee2a Allow MetadataFactory.fetch_http to skip sha256
`MetadataFactory.fetch_http` must often download HTML pages, not
Updates.xml files. download.qt.io does not store checksums for these
files, so this particular function must be allowed to download these
pages without using a checksum.
2022-03-06 18:16:37 -08:00
David Dalcino
05cc2347c7 Merge branch 'master' into topic-fix-453 2021-11-24 22:01:27 -08:00
David Dalcino
db4db6c9a4 Implement --archive-dest feature 2021-11-24 13:30:48 -08:00
David Dalcino
092d4e8c02 Add tests for list-src, list-doc, list-example 2021-11-23 11:08:07 -08:00
David Dalcino
621cd7a6c0 Fix implementation of aqt tool
This modifies `aqt tool` to allow `-` characters in tool versions, so
that `aqt tool` can pass the same unit tests that `install-tool` can.
This makes it less like the `aqt tool` from v1.2.5, but it should work
better with more tools with different version formats.
2021-10-30 19:23:35 -07:00
David Dalcino
4ab854291b Allow Cli._set_arch to receive SimpleSpec 2021-10-28 15:42:10 -07:00
Hiroshi Miura
42564a6f9e PEP8/Black
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-10-19 13:22:14 +09:00
Hiroshi Miura
7accb6f699 Expectation of help message
argparse auto generate message changes a little in 3.10

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-10-16 11:50:47 +09:00
David Dalcino
d5213142a8 Fix misuse of disable_socket (#415)
In an earlier PR, I added calls to `disable_socket()` from
`pytest_socket` where I thought they were needed to prevent some tests
from accessing the network, in case they weren't monkeypatched properly.
Today, I discovered that `disable_socket()` disables sockets globally
for all tests, which means that the tests that use remote data cannot
run if they are executed after another test calls `disable_socket()`.

This change calls `disable_socket()` once from `conftest.py`, so that
no tests are allowed to use network data unless they are marked as ok
to use the network, with `@pytest.mark.enable_socket`. See example of
usage in `tests/test_connection.py`.

Changed return code for unexpected exceptions:

This allows us to write tests that can discover whether an unexpected
exception occurred just by checking the return code, rather than reading
stderr. This will allow us to write less friable tests that don't break
every time some insignificant output details change.

This change catches exceptions derived from Exception and
KeyboardInterrupt raised by `installer`, while run by multiple
processes, and propagates them back to earlier stack entries. This will
prevent any OSError and BrokenPipe exceptions that would otherwise be
raised when one process has an exception while the other processes are
still running.

This also handles the MemoryError exception we saw in #416, and offers
some suggestions for solving the issue.
2021-10-05 14:40:05 +09:00
David Dalcino
e093b6bdf5 fix import mistake 2021-09-30 19:27:57 -07:00
David Dalcino
c5b89f6170 fail on mismatched tool versions
This recreates the legacy behavior, where `aqt tool` would fail to
install a tool variant when the version in the xml file does not match
the version requested in cli arguments.

This also recreates a bug where `aqt tool` cannot install tools that
do not have a valid semantic version.
2021-09-30 19:15:32 -07:00
David Dalcino
4d1b09287e Fix disable_socket() usage 2021-09-30 18:02:17 -07:00
David Dalcino
9fee65ab56 Add test for aqt tool with 4 pos arguments
`test_cli_legacy_commands_with_wrong_syntax` relies on `argparse` to
filter out bad argument lists; the new test uses a mocked getUrl that
raises ArchiveDownloadError.
2021-09-30 14:31:19 -07:00
David Dalcino
a4de09df98 Add tests for the legacy commands 2021-09-30 09:41:09 -07:00
David Dalcino
b67749e4fc Add tests 2021-09-17 14:48:57 -07:00
David Dalcino
1a918c35c5 Merge remote-tracking branch 'upstream/master' into specify-version-by-simplespec 2021-09-09 08:26:10 -07:00
David Dalcino
65293b82ee Implement install-qt by spec 2021-09-07 14:34:26 -07:00
David Dalcino
7856631120 Add tests for new installer exceptions raised 2021-09-06 13:09:27 -07:00
David Dalcino
387bd4a61a Add test for unexpected exceptions 2021-09-06 11:15:27 -07:00
David Dalcino
174daf80d7 Add Cli exception tests 2021-09-01 16:09:53 -07:00
David Dalcino
ebea5231cf Update test_cli: expect cli.run not to raise 2021-09-01 11:44:19 -07:00
Hiroshi Miura
a767956a5b Coding style update by Black/isort
Change to max line length to 125

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-08-02 13:41:41 +09:00
David Dalcino
55c6e94636 Improve language of help text 2021-08-01 13:25:19 -07:00
David Dalcino
9982f56613 Fix syntax of new subcommands in tests 2021-08-01 13:25:05 -07:00
Hiroshi Miura
59b8522cd2 test: cli: Update test expectation
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-08-01 20:56:26 +09:00
David Dalcino
c3d202730c Update tests to use list-qt/list-tool syntax 2021-07-22 09:47:39 -07:00
Hiroshi Miura
a5bb6b7e96 Introduce metadata package (#305)
* Introduce metadata module

that has Versions and ListCommand class

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Introduce custom Version class

A Version class override semantic_version.Version class
that accept qt versions and tools versions

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* PEP8/Black

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Improve test assertion

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Move ArchiveId class to metadata module

And Improve imports

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Refactoring Version class

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Refactoring Table class

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Refactoring Table class(wip)

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix output format of `list tools` command

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* list: Improve print output

avoid str.join()

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-07-13 00:10:36 +09:00
David Dalcino
705c6225e2 Add capability to list tools (#235)
* Add html scraping capability to helper.py

The function scrape_html_for_folders() reads an html file at
`https://download.qt.io/online/qtsdkrepository/<os>/<target>/` and
extracts a list of all the folders within that directory.
It separates the folders by category, so that 'tools' are not
mixed in with 'qt5' or 'qt6'.

This commit also adds a function that prints the available folders,
allowing the caller to filter the output by category.

* Add interface for accessing scrape_html_for_folders

I'm sure this isn't exactly what is needed, and that this functionality
should probably be folded into `aqt list`, but it does demonstrate that
aqt can list all the tools available at downloads.qt.io by scraping html.

This allows you to type `aqt list2 tools linux desktop`, and get a list
of all the tools on the server.
There are more options; type `aqt list2 -h` to see them all.

* Add failing tests for `aqt list`

* Add passing implementation of `aqt list`

* Remove old implementation of `aqt list`

This removes `Cli.run_list_old`, as well as any commented-out code in
installer.py that was related to the old implementation of `run_list`.

This also restores some code that was commented out erroneously.

* Fix misuse of semantic_version

In an earlier commit, I used the parameter `partial=True` for the
preview builds of Qt, since they do not include a patch number. I did
not recognize this as a misuse of semantic_version until I ran the tox
linter. `partial` is meant for 'partial specification', as in, 'this
program requires version 6.2, and the patch is unimportant`.

This change removes the `partial=True` parameter, adds a `0` for the
patch number, and uses a format string to print preview versions without
the patch.

* Use semantic version in interfaces instead of str

This updates all functions that accept a Qt version as a string, so that
they now accept a semantic version object instead. This forces the
caller to do some input validation, and moves the responsibility of
string-to-version conversions out of functions where it does not belong.

* Improve `aqt list` interface as discussed

This adds several new options to `aqt list`, and renames the ambiguous
`packages` to `modules`. New options include the ability to list
targets, extensions, and architectures for a particular (host, target,
Qt version) tuple. The goal is to provide sufficient information to the
user, such that the user can use all the other features of aqt without
having to look them up somewhere else.

* Cleanup `targets` dictionary

* Add `list architectures` feature

* Add tests for `list architectures` feature

* Add documentation for new list feature.

* Fix url bugs related to BASE_URL change

* Add stub for `list --extensions`

* Implement `list --extensions`

* Cleanup imports

* Add basic tests of `aqt list` to azure pipeline

* Fix failed merge with upstream

* Simplify string-to-version code

An earlier commit introduced `cli_2_semantic_version`, which calls
`get_semantic_version_with_dots`, which will never be called by any
other code. I think that this should really just be one function, and
splitting it in two is just needlessly complex.

* Revert dd41e653 - changes to azure-pipelines.yml

* CI: change test case for list command

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Update MANIFEST

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix errors reported by flake8

This commit fixes some unused imports, missing imports, and formatting
errors.

* Run isort

* Add three more build jobs to azure pipelines

This adds three more combinations of `qt version/host/target` to the
`aqt list` command tests on the azure pipelines. This is pretty far from
exhaustive, but I think it's worth it to add these: they execute
slightly different code paths than the standard `linux/desktop`
variants. I don't want to add a whole lot more than this; `aqt list` is
slower than I'd like it to be, and I don't want to waste CI time.

* Fix bug where empty extensions returns success

Prior to this commit, if you ran `aqt list` to list possible extensions,
it could print a blank line and return 0. This is because the
get_extensions_for_version function was accepting empty strings as a
valid extension, and returning a list consisting of one empty string.
This commit filters out those empty strings.

* Attempt to fix ci bug when listing android exts

Android extensions for Qt6 follow different rules than Qt5; this
attempts to account for that.

* remove invalid ArchiveId objects from tests

* Add author

* Use Python for test logic instead of bash

* Remove 'build accelbubble' step from 'list' test

This commit attempts to separate the 'build accelbubble example' test
from the 'aqt list' test.

In this case, the test for `aqt list qt5 linux android` was running the
"build accelbubble example" test in addition to the intended test. If
the "build accelbubble example" test fails, then it looks like the `aqt
list` test failed, until you look to see why it failed.

* Remove dead code

* Accept `latest` keyword instead of qt version

This commit modifies the interface of `aqt list`, so that the flags
`--modules`, `--extensions`, and `--arch` will accept either a Qt
version or the word `latest`. If the user specifies a version of Qt,
the command works as before. If the user specifies `--modules latest`,
`aqt list` will determine the latest version of Qt, given the filters
specified, and return the modules for that version.

This commit removes the flag `--latest-modules`, because that flag is no
longer necessary. The `latest` keyword serves the same function, and it
works for the `--extensions`, and `--arch` flags as well. This prevents
the need for flags such as `--latest-extensions` and `--latest-arch`,
which otherwise would have been necessary to provide this functionality
to the other list features.

* remove unused import

* Update azure pipeline to reflect `latest` feature

* WIP refactor helper methods into ListCommand

* Refactor helper methods into ListCommand

This PR adds many helper methods to helper.py that are closely related
to each other, and which are only useful to the ListCommand object. This
commit moves the majority of these into the ListCommand object, so that
they don't confuse future readers who are looking for something else.

* Fix imports after merge

* Fix unused import

* Add test and impl for list tool modules

This adds code that parses an 'Updates.xml' file for the names of tool
modules, which a user can use to install tools. This does not have any
cli-facing code yet, since the current interface does not make sense for
this purpose.

* Add CLI command to list tool variant names

This exposes `ListCommand.fetch_tool_modules` to the CLI.
Accordingly, it adds a test to the Azure Pipelines for every `aqt list`
job, and it adds documentation to docs/cli.rst.

Since this feature is meant to print values you can feed into the `aqt
tool` command, the documentation for the `aqt tool` command was changed
as well.

* Use monkeypatch for http_fetcher

This removes the http_fetcher parameter for ListCommand in favor of
monkeypatching.

* Remove dataclasses

Dataclasses were new in Python 3.7, and don't exist in the minimum
supported Python 3.6.

* black

* Fix ci test for `aqt list tools --tool`

* Add default timeout to request_http_with_failover

* fix monkeypatched http fetcher

* Fix 'aqt list tools' command on Azure Pipeline

Currently, the `tools_qt3dstudio_runtime_240` appears to be the only
tool available on all host/target combinations, so we will check that
one in Azure Pipelines.

* Move helper classes specific to ListCommand into ListCommand

* Fix use of new global Settings object

* Fix sphinx docstring syntax

* Swap `request_http_with_failover` for `getUrl`

* Add additional follow-up suggestion on error

* Fix exceptions import

* Prevent repeated 'suggested follow up' actions

This change uses exclusive branches to prevent `aqt list` from repeating
the same/similar recommended actions.

* Fix bugs related to updated getUrl error messages

* run black

* docs: add auto section link label extension

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* docs: add more list command examples

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix typo in docs

* remove duplicate `semantic_version`

* Add expected outputs and arch example to docs

This change adds some expected output to the documentation. For any
user who is confused about what the documentation means when it
mentions `tools` and `modules`, and is unsure which is which, this
change should help that user figure that out.

This also adds an example for listing architectures.

* Remove `logger` from `getUrl` parameter list

* helper: getLogger("aqt.helper") in helper functions

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Use `pretty_print` instead of `str()` for output

* test_list.py use pretty_print instead of str

* fix Versions constructor

* black

Co-authored-by: Hiroshi Miura <miurahr@linux.com>
2021-07-06 07:58:18 +09:00
David Dalcino
5d5bae28ab run black 2021-07-01 12:04:37 -07:00
David Dalcino
70733c047b Add tests for install, doc, list 2021-07-01 12:03:26 -07:00
David Dalcino
049be1cfca Add test for invalid versions
This test checks that when a user inputs an invalid version string
when running the installer, aqt detects the error and asks the user to
fix it, rather than raising `ValueError`.
2021-07-01 11:43:30 -07:00
Hiroshi Miura
f35edf398a Fix logging in installer sub-process when multiprocessing context with spawn method (#273)
* Simplify logging

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Update logging

- keep logging file path in Settings
- introduce installer logger

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* PEP8/Black

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Logging: add queue handler

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Logging: introduce logutils module

- Add QueueListenerHandler
- Add queue listener handler config
- qualname to aqt.installer

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Logging: introduce aqt.updater logger

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Logging: introduce aqt.main and aqt.archives logger

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* PEP8/Black

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Logging: simplify config file

- use propergate for last output handler
- change formatter
  * console: brief
  * file: verbose
- Use multiprocessing.Queue() instead of queue.Queue()
- Remember logging config file customization in Settings
- QueueListener use handler as of getLogger("aqt").handlers

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* change log level of redirection

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Logging: Single global LoggingQueueListener

- Global instance of LoggingQueueListener
- Drop queue_listener from logging.ini
- Generate QueueHandler from LoggingQueueLisnter.get_queue_handler
- Explicitly close QueueListenerHandler and Queue object.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* CI: use verbose console logging for ci

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* CLI: drop options to specify logger and logger configuration file

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Make Instance of LoggingQueueListener in Cli class

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Handle QueueListener in Cli.call_installer

- Use mp.Manager().Queue()
- start(), stop() in caller
- Gracefully close QueueHandler in installer

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* PEP8

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Drop berkeley.edu from fallbacks of mirror site

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix log format of time digits

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Update settings load

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* CI: catch custom settings from change in master branch

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Show log when loading custom settings

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Improve subprocess logging that use root logger

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* fix logging.ini settings

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Fix against tests

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Introduce MyQueueListener

- Inherit System QueueListner to override logger name

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* PEP8/Black

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-06-21 15:25:00 +09:00
Hiroshi Miura
49fc8ec6b1 Version subcommand
- Set aqt version by version.py generation
- Drop importlib and pkg_resources chunks of code

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-06-11 08:34:43 +09:00
Hiroshi Miura
b066a8654c Drop feature to install old versions
The feature is infeasible to maintain, so drop the feature from release.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-05-24 11:27:34 +09:00