Commit Graph

600 Commits

Author SHA1 Message Date
Florian Bruhin bc191b798d wmname: Remove trivial functions 2025-11-11 09:06:49 +01:00
Jan Palus 25dc019886
Unify librarry loading for X11/Wayland wmname
libwayland-client.so is development symlink used during linking and there's no need to
have it installed (usually shipped in -devel/-dev packages) on user's machines. Instead
of hardcoding library file name, use same mechanism as in libX11 which let's Python
figure the details and share common logic between X11 and Wayland.

Fixes #8771
2025-11-11 00:51:05 +01:00
Florian Bruhin aa93eb1614 Adjust stack trace parsing for newer Python 2025-11-03 16:26:12 +01:00
Florian Bruhin 00b3bba99a Qt 6.10: Disable Hangouts extension via API
See https://github.com/qutebrowser/qutebrowser/issues/8694#issuecomment-3276414407
2025-10-22 21:45:48 +02:00
Florian Bruhin 226d167ec7 Qt 6.10: Skip incompatible pakjoy tests
See https://github.com/qutebrowser/qutebrowser/issues/8694#issuecomment-3276414407
2025-09-17 15:35:22 +02:00
Florian Bruhin e7af54898e Add X11/Wayland information to version info
Unfortunately there is no way to get this information from Qt, so I had to
resort to some funny low-level C-like Python programming to directly use
libwayland-client and Xlib. Fun was had! Hopefully this avoids having to ask
for this information every time someone shows a bug/crash report, as there
are various subtleties that can be specific to the Wayland compositor in use.
2025-06-25 09:34:35 +02:00
Florian Bruhin 959dc5a9e5 tests: Correctly deactivate SignalHandler after tests
Otherwise, the python_hacks timer might continue running
and affects test_early_timeout_check, similiarly to what was fixed in
74c7ff2641.
2025-06-06 10:53:38 +02:00
Florian Bruhin 072b03a631 Avoid version warnings with PyQtWebEngine-Qt5 5.15.17
With PyQtWebEngine-Qt5 5.15.17 (Qt 5.15.19), we seem to run into similar issues
like we already did with Qt 6.5:

https://github.com/qutebrowser/qutebrowser/issues/7624#issuecomment-1474008470
9cb54b2099

However, skipping the ELF test is not enough, as we also get warnings
at runtime (as we don't have any API to get the version at runtime).

We don't care much about Qt 5 at this stage, so let's just not output
warnings in that case (and nothing in the code should care about the exact
QtWebEngine patch level beyond 5.15.2 anyways).

For most user-facing things, we *can* get the exact version number from
the user-agent, so this should not actually affect much.
2025-05-29 23:42:40 +02:00
Florian Bruhin 97104b2000 Use builtin list/dict/set/... types for annotations
See https://peps.python.org/pep-0585/
and https://docs.python.org/3/whatsnew/3.9.html#type-hinting-generics-in-standard-collections

Done via:

    ruff check --select 'UP006' --fix --config 'target-version = "py39"' --unsafe-fixes

followed by removing unused imports:

    ruff check --select 'F401' --fix --config 'target-version = "py39"'

and a semi-manual review to find imports that are still needed (but ruff doesn't know about yet):

    git diff | grep '^-' | grep import | grep -v "from typing"

Also see #7098.
2024-10-15 11:54:49 +02:00
Florian Bruhin 4d069b8fc3 Use str.removeprefix() and str.removesuffix()
https://docs.python.org/3/whatsnew/3.9.html#new-string-methods-to-remove-prefixes-and-suffixes
2024-10-13 18:24:44 +02:00
Florian Bruhin bcff1e90ea Update checkpyver for 3.8 drop 2024-10-13 18:24:44 +02:00
toofar 779bb73920 Update pakjoy and chromium versions for Qt6.8
Looks like the kde-unstable arch repo has updated again. It says
6.8.0beta2-1.

I guess the number might change again in the future, still a couple of
months to go before release.
2024-07-28 16:00:17 +12:00
Florian Bruhin 5003929cdd pakjoy: Fix Qt 5 tests 2024-07-15 08:11:10 +02:00
Florian Bruhin 6e84639276 pakjoy: Test behavior when explicitly enabled 2024-07-14 22:14:00 +02:00
Florian Bruhin dfcb6e3f7c pakjoy: Improve error message and add test 2024-07-14 22:04:56 +02:00
Florian Bruhin 2088ecebd9 pakjoy: Add more hardcoded IDs and fix tests 2024-07-12 16:00:52 +02:00
Florian Bruhin bcf792a0dc Add more hardcoded IDs and tests 2024-07-12 15:28:38 +02:00
Florian Bruhin 63b5708bae Revert "adjust test strings for incrementing connection IDs"
This reverts commit ccebbd6ebb.
2024-05-25 14:49:51 +02:00
toofar 669795058b Handle "early timer" log messages in tests
The `test_cleanup()` test for guiprocess was triggering the early timer
warning messages because it was using a VeryCourse timer with a 100ms
interval. Changed it to to a normal Course timer (the default) for that
test.

For the `ipc-timeout` timer we know that is happening in the tests on
windows. It's being logged in lost of e2e tests, the elapsed times it's
logging are between 0 and 0.020s. I'm not sure if it's the right thing
to be changing the log level in production code or marking the messages
as expected in test code.
2024-05-25 09:34:01 +12:00
toofar ccebbd6ebb adjust test strings for incrementing connection IDs 2024-05-25 09:34:01 +12:00
Florian Bruhin a7a7c434e2 Fix handling of missing QtWebEngine resources
I was getting crash reports from someone about this. Not sure what's going wrong
there (hence the additional information in the exception).

What's clear however is that we're raising ParseError, but only handling that
when actually parsing. The code calling copy_/_find_webengine_resources only
handles OSError. So let's raise a FileNotFoundError instead.
2024-05-10 18:41:50 +02:00
toofar 145bfe4de0 windows doesn't support SIGHUP
It gives an AttributeError for both signal.SIGHUP and
signal.Signals.SIGHUP. The Signals Enum is set up so you can use the
strings to key into it though, so that's nice. I was tempted to use a
walrus operator here but I think that's python 310 and I don't remember
what our minimum supported version is.
2024-02-25 15:56:34 +13:00
toofar f6c0e4ebc8 Add some basic tests for SignalHandler
It doesn't look like this class has any unit tests currently. And since
we are adding a new signal handler to it I took the opportunity to add a
few tests to it to establish a bit of a framework so that next time we
touch it it will be easier to add more.

I didn't go for full coverage here. It's an improvement over what was
there previously and it should make merging more palatable. I don't
think handling SIGHUP is a very risky feature.

I chose to use mocker.patch over monkeypatch.setattr because I think it
provides a more friendly and powerful API due to being more tightly
integrated with magic mocks. And with `mocker.patch.object` you can even
use actual object names instead of strings, the same as monkeypatch
allows.

One thing I'm less confident with here is mocking all multiple things in
a couple of fixtures. Writing one fixture for each little thing I mock
doesn't feel appealing to me right now, but for mocks that tests need to
access there isn't really any idiomatic way to let the tests access
them. I previously just had the one fixture but pulled out the read
config one for that purpose. It's a pattern I'll have to think on a bit
I think. Probably having to have developers thing about the balance of
boilerplate vs accessibility is cognitive load that we want to avoid.
Hmm.

Anyway, here are the options I was looking at to let test code access
mocks that where all shoved away into the one fixture:

1. group the tests into a class and put the mocks in class variables:
   could work fine but I don't think it's very idiomatic for pytest?
2. return some kind of meta object from the fixture that has the object
   under test as one attribute and the mocks as other ones: hmm,
   returning multiple values from a method always seemed a bit smelly to
   me
3. make one fixture for each of the mocks, have the main fixture depend
   on them all, tests that need to modify them can depend on them too:
   writing all those fixtures seems tedious and I don't think it would
   be a clear win in terms of readability. *sigh*, I suppose I should
   pull the ones I'm modifying out at least so other people don't copy
   my lazyness in the future
4. have the test code access the mocks from the real code, eg
   `configfiles.sys.exit.side_effect = ...`: this works fine but I feel
   like it's relying on an implementation detail and probably shouldn't
   be encouraged? Not sure

In case anyone is struggling with git blame and wondering what the
QSocketNotifier stuff is about, this commit should explain it: 210ce8ca7c
2024-02-24 23:23:42 +13:00
Florian Bruhin 9d8c263e9a Extend pakjoy to Qt 6.5.0/.1/.2 with dark mode
See #7837
2023-12-05 13:46:02 +01:00
toofar 1aa3c952ab pakjoy: fix happy path test
read back the manifest inside the context manager so we can find the
work dir.
2023-12-02 12:41:23 +13:00
Florian Bruhin 302a8f582a pakjoy: Restore old QTWEBENGINE_RESOURCES_PATH value
Otherwise, doing :restart fails because it tries to copy quirk dir to quirk dir.

QtWebEngine reads the env var in resourcePath() in
src/core/web_engine_library_info.cpp. That only seems to be called from
WebEngineLibraryInfo::getPath(), and that in turn gets called from
ResourceBundle::LoadCommonResources() in src/core/resource_bundle_qt.cpp.

Finally, that only seems to be called during Chromium initialization, so it
seems alright for us to unset this as soon as we initialized the first profile.

It also seems to work fine in my testing on Google Meet, and indeed fixes
:restart.
2023-12-01 22:47:43 +01:00
Florian Bruhin bd86577736 pakjoy: Add undocumented escape hatch 2023-11-22 22:23:53 +01:00
Florian Bruhin 8a53e9b282 pakjoy: Use proper logic to discover resources dir 2023-11-22 20:14:33 +01:00
Florian Bruhin 2e2e0c8031 pakjoy: 100% test coverage 2023-11-22 18:02:18 +01:00
Florian Bruhin 6147cae901 pakjoy: Use existing tmp_cachedir 2023-11-22 18:02:18 +01:00
Florian Bruhin 6b7eb77c4d pakjoy: Run black 2023-11-22 18:02:18 +01:00
Florian Bruhin 9e3d421a15 pakjoy: Use declarative skipping in tests 2023-11-22 18:02:18 +01:00
Florian Bruhin 51dace7152 pakjoy: Use more constants 2023-11-22 18:02:18 +01:00
Florian Bruhin 50db87664d pakjoy: Remove existing work dir if unneeded 2023-11-22 18:02:18 +01:00
Florian Bruhin 23d6a331f7 pakjoy: Fix test_elf.py 2023-11-22 09:58:26 +01:00
Florian Bruhin 2787d2382a pakjoy: Separate _patch and patch_webengine 2023-11-22 09:32:23 +01:00
Florian Bruhin b4ad0c559d Fix another merge issue 2023-11-22 09:25:13 +01:00
toofar f26a477d7c add tests for pakjoy
There is one test which does does the whole run through with the real
resources file from the Qt install, patches is to the cache dir, reads
it back and checks the json. All the other tests either use constructed
pak files or stop on earlier error cases.

For testing the actual parsing of the pak files I threw together a quick
factor method to make them.

I went back and forth over the parse code and looked for more error
cases, but it looks pretty solid to me
2023-11-05 17:48:11 +13:00
Philipp Albrecht 86925b58cb Rename :repeat-command to :cmd-repeat-last
Group commands related to commands/commandline by prefixing them with `cmd-`. In this
case we additionally renamed the command slightly to fit better with the `cmd-` prefix.
2023-08-11 09:02:12 +02:00
Florian Bruhin 8ddaef35d0 reuse: Fix more copyright headers
See previous commit, forgot ? after year range
2023-07-23 12:56:13 +02:00
Florian Bruhin 3eb826f664 reuse: Update remaining copyright texts
git ls-files | \
    xargs sed -Ei 's/Copyright [0-9]{4}(-[0-9]{4}) ([^<]*)<([^>]*)>/SPDX-FileCopyrightText: \2<\3>/'
2023-07-23 12:52:01 +02:00
Florian Bruhin 0718b25796 reuse: Initial copyright text update for myself
git ls-files | \
    xargs sed -Ei 's/Copyright [0-9]{4}(-[0-9]{4}) Florian Bruhin \(The Compiler\) <mail@qutebrowser\.org>/SPDX-FileCopyrightText: Florian Bruhin (The Compiler) <mail@qutebrowser.org>/'
2023-07-23 12:49:05 +02:00
Florian Bruhin b2aaba6043 reuse: Adjust most license headers
git ls-files | xargs grep -l "is free software"  | xargs reuse annotate --license="GPL-3.0-or-later" --skip-unrecognised
2023-07-23 12:11:07 +02:00
Philipp Albrecht d9e8b638bf Remove vim modelines
We're deprecating vim modelines in favor of `.editorconfig`.

Removing vim modelines could be done using two one-liners. Most of the vim modelines
were followed by an empty line, so this one-liner took care of these ones:

```sh
rg '^# vim: .+\n\n' -l | xargs sed -i '/^# vim: /,+1d'
```

Then some of the vim modelines were followed by a pylint configuration line, so running
this one-liner afterwards took care of that:

```sh
rg '^# vim:' -l | xargs sed -i '/^# vim: /d'
```
2023-06-30 11:03:06 +02:00
Florian Bruhin 93c7fdd60c Initial Python 3.7 drop 2023-06-26 14:39:54 +02:00
Florian Bruhin 48ea86fcb5 Rename some qt6 FIXMEs
Not relevant for v3 and qt6
2023-06-25 23:32:59 +02:00
Florian Bruhin 89b81c4b3a tests: Widen xfail range for ELF to Qt 6.6+ 2023-06-15 16:24:21 +02:00
Florian Bruhin 368061dc3d Merge branch 'update-dependencies' 2023-05-31 15:49:46 +02:00
Florian Bruhin e65325ae4d Also skip ELF test on Qt 6.5.1
See #7624
2023-05-31 13:07:34 +02:00
Florian Bruhin feae08cbc2 Skip process message test on Windows 2023-05-31 12:23:09 +02:00