Commit Graph

50 Commits

Author SHA1 Message Date
Dave Dalcino
c3195c9d64 Use 'tar' filter when extracting tarfiles
This is to address a SNYK warning. The new code will only run on Python
3.11.4 and above
2023-08-27 18:45:46 -07:00
Dave Dalcino
7c0de86f78 Add tests for sdktool: install-tool and list-tool 2023-05-24 15:38:13 -07:00
Dave Dalcino
c9732c7c2c Fix broken test 2023-03-25 11:45:15 -07:00
Dave Dalcino
e4fa75147f Test nonspecific OSError 2023-03-14 01:24:03 -07:00
Dave Dalcino
8dd56ff461 Catch OSError(errno.ENOSPC) and PermissionError
When the destination drive is not writable or has insufficient space,
these exceptions are raised during `run_installer`. Unless they are
caught and dealt with, `aqtinstall` requests that the user file a bug
report. This change catches these errors and prints a nice error message
instead of requesting a bug report.
2023-03-13 17:48:09 -07: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
e30d3198a4 Fix errors in install-* caused by duplicate 'modules'
Fixes #632
2023-01-07 06:57:28 -08:00
Hiroshi Miura
0f1010baee Load settings.ini in child process
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2022-12-05 19:50:51 +09:00
Dave Dalcino
839cf6e2f3 Patch according to new installscript.qs rules
This removes the inappropriate ENV variables set in steps.yml.
It's not wrong to set those variables, but the official Qt installer
patches the defaults properly, so you don't have to do it manually.
It's wrong to expect our users to set these.

This also patches target_qt.conf to add HostLibraryExecutables.
2022-12-04 16:44:45 -08:00
Dave Dalcino
6db730e659 fix backslashes on windows 2022-12-04 10:42:49 -08:00
Dave Dalcino
18c8259e8c Set executable file permissions for qmake 2022-12-04 10:42:48 -08:00
Dave Dalcino
0cc15b31c6 Add tests for android qt 6.4.1, using "wrong" platforms
Since Qt 6.4.1, the Qt devs stopped building android binaries for
all platforms: see https://bugreports.qt.io/browse/QTBUG-108707

> we are building android packages only in one host & use those in other ones:
> android armv7 is build only in windows
> android arm64 is build only in mac
> android x86 and android x86_64 are build only in linux

This adds tests for Qt 6.4.1 on platforms that are not the platforms that
Qt was built for, so that:
* the binaries built on Mac are tested on Linux
* the binaries built on Linux are tested on Windows
* the binaries built on Windows are tested on Mac

There should be 3 more permutations of this pattern, but I prefer to
ignore them to save on CI build times.
2022-12-02 17:31:53 -08:00
Dave Dalcino
24f6d9ddca Add cli tests for long_modules and modules with archives
This should cover the new lines of uncovered code in this PR.
2022-11-21 07:34:46 +09:00
Dave Dalcino
d73c89a89f fix expected error message in test cases 2022-11-14 19:23:44 -08:00
Dave Dalcino
e716a7805a Add test for uncovered code 2022-10-12 18:10:15 -07:00
David Dalcino
3bb364b301 Fix type error 2022-08-20 09:28:50 -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
861a3d6b61 Improve install test patch specificity 2022-08-20 09:04:52 -07:00
Dave Dalcino
ed6cf76968 Add CLI option to install desktop qt automatically
This change also causes aqt to emit a warning when the option is not
turned on and the expected desktop Qt is not found.
2022-08-20 07:53:00 -07:00
Dave Dalcino
317bf64ace Add direct test that MetadataFactory receives base_url 2022-08-07 11:34:49 -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
ad20856738 Fix patching of Qt6.2.2-ios (#510)
* Add tests for proper patching of Qt6.2.2-ios
* Add a build target for ios installations
* Add test coverage for mobile patching on linux

This change folds in some refactoring as well, in an attempt to reduce
repetitive logic, and make sure that this logic is used everywhere appropriate.
2022-04-04 14:22:13 +09:00
David Dalcino
49a6cf97b6 Remove unnecessary usage of eval function 2022-03-10 18:29:18 -08:00
David Dalcino
be23b62549 Update tests to require proper checksums 2022-03-06 17:56:25 -08:00
David Dalcino
96af3eb393 Refactor: split QtArchive.archive_url into parts
This splits QtArchive.archive_url into two new datamembers: archive_path
and base_url. Ultimately, base_url should be removed from QtPackage
entirely.
2022-03-06 17:36:32 -08:00
David Dalcino
7ebd6aa34e Use sha256 hashes only from trusted mirrors
To keep this commit small, `hashurl` was removed from QtPackage, and
`get_hash` constructs the hash url based on the url of the 7z archive
to download. I think that in the future, QtArchive and QtPackage could
be refactored to construct this url more appropriately. However, this
would be a complicated change that doesn't belong in this commit.
2022-03-06 17:36:32 -08:00
David Dalcino
05cc2347c7 Merge branch 'master' into topic-fix-453 2021-11-24 22:01:27 -08:00
David Dalcino
3af9c97ba0 Refactor: Allow modifiable download dest path
This adds the parameter `archive_dest` to `run_installer`, which will
control where `helper.downloadBinaryFile` will download files, and sets
it to "." by default.

For convenience/readability, this will also turn any reference to the
downloaded file into a `pathlib.Path` object. This makes it easier to
ensure that the file ends up in the right location.
2021-11-24 13:29:20 -08:00
David Dalcino
cfc241002d Fix suggestions for src/doc/ex missing modules 2021-11-23 12:17:03 -08:00
David Dalcino
b736130f90 flake 2021-11-23 11:42:06 -08:00
David Dalcino
c7320cb0f1 Improve CI & tests for install-src/doc/example
This updates CI and unit tests to monitor behavior of
`install-src/doc/example`, now that the `target` parameter has been
deprecated. This makes sure that the `target` parameter is optional,
and that the CLI warns the user that `target` is deprecated when a user
uses it.

[CI tests]:
This adds a test to `install-src/doc/example` Azure Pipeline jobs to
ensure that the desired files are installed, using `ls`.

This also changes some of the archives installed to `qtlottie`, which
is a particularly small file.

This also adds a build job for `install-example`.

[Unit tests]:
This adds tests for `install-src`, with and without the `target`
parameter.

It also fixes existing tests for `install-doc`, to account for
changes to the `target` parameter.
2021-11-23 11:10:06 -08:00
David Dalcino
7638d87d6c Add unit test for install-tool & tool 2021-10-30 19:23:35 -07:00
David Dalcino
173fbb9b6b Add suggestion on MemoryError to use external 7z 2021-10-29 11:08:15 -07:00
David Dalcino
cf5ca6e468 Add test for --noarchives flag 2021-10-20 19:21:22 -07: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
776ab6181f Propagate exceptions from run_installer()
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-02 18:26:03 -07:00
David Dalcino
a5bb2553ce Add improved error messages for missing archives 2021-09-20 12:46:47 -07:00
David Dalcino
7856631120 Add tests for new installer exceptions raised 2021-09-06 13:09:27 -07:00
David Dalcino
cfd4234877 Expect Cli.run not to exit on connection errors 2021-09-01 12:36:29 -07:00
David Dalcino
425421f0bb Add test to install missing modules
The previous tests only test the QtArchive classes; this test covers
what happens when invalid modules are passed to a Cli object.
2021-08-25 15:04:07 -07:00
David Dalcino
c3c22ded20 fix import order 2021-08-18 10:42:51 -07:00
David Dalcino
384950794a Add tests that install modules 2021-08-18 10:17:33 -07:00
David Dalcino
1c4f96736c Fix expected install directory for Qt 5.9 2021-08-11 12:05:43 -07:00
David Dalcino
a0222edcf8 Add unit tests for Qt 5.9 installation 2021-08-11 11:26:38 -07:00
Hiroshi Miura
4e6fe665ab Black/PEP8
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-08-06 08:12:13 +09:00
David Dalcino
bc2945687c Rename autoused fixture more appropriately 2021-08-04 15:47:40 -07:00
David Dalcino
ec99247bad Monkeypatch multiprocessing.Manager 2021-08-04 15:47:10 -07:00
David Dalcino
e94ee842bb Allow platform-dependent path separators 2021-08-04 15:46:23 -07:00
David Dalcino
c95516ed8e Remove re.Pattern type hint
In Python 3.6, `re.Pattern` does not exist, and using it as a type hint
causes the tests to fail. This change enables the tests to run on
Python 3.6.
2021-08-04 15:43:56 -07:00
David Dalcino
66f1231444 Add 'tests/test_install.py'
This change adds unit tests for the `aqt install` and `aqt install-qt`
commands, and establishes a pattern that can be extended for more
tests. This is intended to make it easier to increase test coverage of
parts of the codebase that are not yet covered by tests.

This uses the `pytest-socket` library to ensure that the tests do not
use any network IO. It also mocks `multiprocessing.get_context` to
prevent multiprocessing. This is necessary because multiprocessing
spawns child processes that have not been monkey-patched, which would
break the test.

These tests use py7zr to create mock 7z archives, which are installed
and patched in a temporary directory. The tests check the content
of the patched files and any output to stderr.
2021-08-03 16:06:47 -07:00