Commit Graph

256 Commits

Author SHA1 Message Date
Florian Bruhin d80d80b867 Qt 6.10: Adjust CI test skipping 2025-07-21 13:47:45 +02:00
Florian Bruhin eca17870ae tests: Extend Qt 6.9.0 workaround to .1
Still seems to be failing, see https://github.com/qutebrowser/qutebrowser/issues/8444#issuecomment-2569610110
2025-06-06 11:30:27 +02:00
Florian Bruhin 3280c8dacc tests: Avoid CI issues with qutescheme and Qt 6.9
see #8536
2025-04-08 14:03:26 +02:00
Florian Bruhin a460770414 tests: Adjust qt69_ci_flaky 2025-03-21 11:29:32 +01:00
Florian Bruhin 328b5966ef Add initial support for running tests offscreen
Makes

    QT_QPA_PLATFORM=offscreen pytest

pass.

See #4914
2025-03-12 14:41:50 +01:00
Florian Bruhin 4cc67d3603 Qt 6.9: Force software rendering for tests
Not yet quite sure what exactly is the culprit, but this seems to help for all
tests (!) to pass with Xvfb locally.

For now only scoped to Qt 6.9.0. Will probably already need to reevaluate with
the RC, but definitely with the final release.

See #8444
2025-03-12 14:41:32 +01:00
Florian Bruhin 8c2cfe8f7e tests: Fix handling of qapp_args
Until now, if the seccomp bpf sandbox needs to be disabled,
PaintHoldingCrossOrigin was not disabled anymore.
2025-03-12 11:32:22 +01:00
Florian Bruhin 0a32d6fef5 Fix qt69_ci_flaky marker
Follow-up to ed8141cb4b
2025-01-09 11:51:45 +01:00
Florian Bruhin 977c90939c tests: Add --qute-strace-subprocs flag
Was needed for #8444 debugging, but might be useful for other issues with
qutebrowser subprocesses as well.
2025-01-06 12:30:19 +01:00
Florian Bruhin 3934d727e4 Qt 6.9: xfail failing test on CI for now
Probably not our fault, and shouldn't break CI until we figure out what could be
going on there...

See https://github.com/qutebrowser/qutebrowser/issues/8444#issuecomment-2569610110
2025-01-03 19:04:36 +01:00
Florian Bruhin 960d9aaaa5 tests: Initialize QtWebEngine spell dictionary path earlier
Turns out there are various places in the tests that somehow cause Qt to start
caching the dict location, not just actually accessing
.[is|set]SpellCheckEnabled() like I originally assumed.

Thus, move setting QTWEBENGINE_DICTIONARIES_PATH into conftest.py so it's run
before any tests. However, remove the sanity check after, as that requires
initializing a QWebEngineProfile which we might not always want to do when
running a subset of unit tests. If something goes wrong with this, chances are
we'll only notice later in the tests anyways.

Follow-up to db8e508530
See #8330
2024-12-09 17:26:12 +01:00
Florian Bruhin a04126b22b hypothesis: Inherit our CI settings from hypothesis CI profile
See 13c3785854

deadline=None and suppressing the too_slow health check is already part of that.
Also fixes a hypotheses -> hypothesis typo.
2024-11-10 19:40:54 +01:00
Florian Bruhin d49675eeed Remove outdated version check 2024-10-22 18:10:19 +02:00
toofar 3852f12091 Don't list each screenshot name in pytest report
This bit is printed right about the test result summary, so now that the
file names are just test names, printing them out just above the full
test paths in the results seems a bit redundant.
The section header prints out the file path with the screenshots and
that's the important part. It looks fine to me printing a section header
without any section contents. Example:

    -------------------- End2end screenshots available in: /tmp/pytest-of-user/pytest-108/pytest-screenshots ---------------------
    =================================================== short test summary info ====================================================
    FAILED tests/end2end/features/test_completion_bdd.py::test_deleting_an_ornpen_tab_via_the_completion - AssertionError: assert 'http://local...ata/hello.txt' == 'http://local...ata/sello.txt'
    FAILED tests/unit/utils/test_resources.py::TestReadFile::test_glob_deleting_resources_subdir[True-pathlib] - AssertionError: assert ['html/subdir...ir-file.html'] == ['html/subdir...ir-sile.html']
    FAILED tests/unit/utils/test_resources.py::TestReadFile::test_glob_deleting_resources_subdir[False-zipfile] - AssertionError: assert ['html/subdir...ir-file.html'] == ['html/subdir...ir-sile.html']
    FAILED tests/unit/utils/test_resources.py::TestReadFile::test_glob_deleting_resources_subdir[True-zipfile] - AssertionError: assert ['html/subdir...ir-file.html'] == ['html/subdir...ir-sile.html']
    FAILED tests/end2end/features/test_utilcmds_bdd.py::test_cmdrepeatlast_with_modeswitching_command_deleting - AssertionError: assert 'http://local...ata/hello.txt' == 'http://local...ata/sello.txt'
    FAILED tests/unit/utils/test_resources.py::TestReadFile::test_glob_deleting_resources_subdir[False-pathlib] - AssertionError: assert ['html/subdir...ir-file.html'] == ['html/subdir...ir-sile.html']
    =========================================== 6 failed, 23 passed, 8 skipped in 22.59s ===========================================
2024-08-24 23:12:55 +12:00
toofar 0c3807b04a Add pytest report section listing e2e screenshots
I would like it to be obvious to contributors who run the tests locally
that there are screenshots of the processes under test that they can
examine. I don't think it's obvious that there could be useful files
sitting round in a temp directory.

This commit adds the screenshot file paths to a user property on failed
tests then adds a custom report section that pulls that lists those
properties. That way when there is errors users will get the paths to
the images printed out alongside the report of failed tests.

I find it difficult to navigate the internals of pytest. I tried various
ways of printing information and getting that information to methods
that could do the printing but couldn't get anything to work. I ended up
entirely copying this SO post which worked really well for attaching
information to test results in a place that is accessable to the
reporting hook: https://stackoverflow.com/a/64822668

It's added to the end of the existing terminal report hook, because
while it seems you can have two of those hooks, things can get pretty
confusing with interleaved reports and not all of them running every
time.

    --------------------- End2end screenshots available in: /tmp/pytest-of-user/pytest-56/pytest-screenshots ---------------------
    2024-08-17T14_49_35.896940-tests_end2end_features_test_utilcmds_bdd.py__test_cmdrepeatlast_with_modeswitching_command_deleting.png
    2024-08-17T14_49_37.391229-tests_end2end_features_test_completion_bdd.py__test_deleting_an_open_tab_via_the_completion.png
    =================================================== short test summary info ====================================================
    FAILED tests/end2end/features/test_utilcmds_bdd.py::test_cmdrepeatlast_with_modeswitching_command_deleting - AssertionError: assert 'http://local...ata/hello.txt' == 'http://local...ata/sello.txt'
    FAILED tests/end2end/features/test_completion_bdd.py::test_deleting_an_open_tab_via_the_completion - AssertionError: assert 'http://local...ata/hello.txt' == 'http://local...ata/sello.txt'
    ====================================================== 2 failed in 5.18s =======================================================

From adding debug messages I can see:

    RUNNER_TEMP=/home/runner/work/_temp
    /tmp/pytest-of-runner/pytest-0/pytest-screenshots

Means that I don't think GHA will be able to collect the temp files
because they are not being written to the temp dir being mounted in from
outside. I think that's the case anyway. Might have to pass
--basetemp=$RUNNER_TEMP to pytest or set TEMP or something. TODO
2024-08-18 12:42:35 +12:00
toofar d0422a982f Tips for contributors to run the webkit backend
My virtualenv I used to run webkit has rotted long ago and I don't remember
how I set it up. There is a PyQtWebKit project on PyPI but I don't know
who that's published by.

So I figured I would write some notes for myself on using the docker container
used for CI instead. I chose to mount the current directory (which is
presumably a qutebrowser checkout!) directly into the container instead of
cloning it so I could have quicker feedback between making code changes and
running tests.

Then there's a couple of things that stem from that. Since the user in the
container is different from the one in the host we have to move some things
that are normally written to the current directory to be written elsewhere.
There are other ways to approach this (eg you can add `-u $(id -u)` to the
docker command line, although that makes things a bit confusing in the
container) but arguably it's good for the container not to be able to write to
the host, hence making that volume read only.

The TOX_WORK_DIR trick is from
[here](https://github.com/tox-dev/tox/issues/20), apart from with
`{toxinidir}` in it too because the pyroma env was failing with just
`.tox`, saying the pyroma binary needed to be in the allowlist, possibly
it was doing full path matching without normalizing.

The hypothesis folks
[here](https://github.com/HypothesisWorks/hypothesis/issues/2367#issuecomment-595524571)
say if you want to override the examples DB location with an env var to
do it yourself. It's actually only a warning from hypothesis, it says it
falls back to an in-memory DB, but I guess the tests run with
warnings-are-errors. You can also pass `database=None` to make
hypothesis skip example storage altogether.

I'm using tox to run commands in a virtualenv with the right stuff in it
because, uh, because I was copying the CI workflow actually. I just found out
about the `exec` subcommand to override the `commands` defined for the env,
neat! One point of awkwardness about that is that since we are using the
PyQt from the OS we need any virtualenv we use to have access to the OS
packages, which isn't the default for virtualenvs created by tox. The
text envs use the link_pyqt script for that but if you are using this
container and the first thing you do is run `tox exec` then that
wouldn't have been run. So I'm setting `VIRTUALENV_SYSTEM_SITE_PACKAGES`
to tell tox to always make the system packages available in the
virtualenvs it manages.

I did try using the mkvenv script instead of tox but it complained when
trying to install the current directory in editable mode because
setup.py tries to write to a git-commit-id file.
2024-06-23 20:12:38 +12:00
Florian Bruhin 4b11776f76 tests: Upgrade our hook implementation for pytest 7
https://docs.pytest.org/en/7.4.x/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path
https://docs.pytest.org/en/7.4.x/reference/reference.html#std-hook-pytest_ignore_collect

8.0.0 removes the "path" compatibility alias we used.
2024-01-10 14:41:39 +01:00
Florian Bruhin ea7fb86706 tests: Also disable PaintHoldingCrossOrigin for unit tests
See https://bugreports.qt.io/browse/QTBUG-112017 and #5390
2023-11-22 22:08:24 +01:00
Florian Bruhin 96805e7d62 Remove hypothesis health check suppression
See https://github.com/HypothesisWorks/hypothesis/pull/3734
2023-09-11 11:11:26 +02:00
Florian Bruhin 04bd4117ad tests: Fix derp 2023-09-08 19:37:40 +02:00
Florian Bruhin 855be48b02 Fix lint 2023-09-08 19:16:26 +02:00
Florian Bruhin 3fabc8fe37 tests: Ignore false-positive (?) hypothesis health check
See https://github.com/HypothesisWorks/hypothesis/issues/3733
Should fix nightly builds (and the next dependency upgrade).
2023-09-08 12:04:37 +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 83bef2ad4b qt: Add machinery.SelectionInfo 2023-06-13 12:09:48 +02:00
toofar 856fe781a1 Merge remote-tracking branch 'upstream/qt6-v2' into master-qt6 2023-03-18 16:24:58 +13:00
Florian Bruhin 4793070db3 Merge branch 'qt6-v2' into master-qt6 2023-03-17 20:30:13 +01:00
Florian Bruhin cd5624f50a tests: Fix QApplication arguments
With Qt 6.5, QtWebEngine complains and aborts when it gets an empty argv:
https://bugreports.qt.io/browse/QTBUG-110157
https://codereview.qt-project.org/c/qt/qtwebengine/+/455347
https://codereview.qt-project.org/c/qt/qtwebengine/+/457045
https://www.riverbankcomputing.com/pipermail/pyqt/2023-March/045216.html

However, our custom qapp_args override for pytest-qt *does* return [] as
argv, causing all tests using QtWebEngine to fail.

We might decide to add sys.argv[0] to the given qapp_args in pytest-qt:
https://github.com/pytest-dev/pytest-qt/issues/483

But probably this should be fixed on the application-side, so let's do
exactly that.

See #7624
2023-03-17 20:09:26 +01:00
toofar ff8dbc4580 lint: broad-exception-raised
Mostly pretty lazy fixes. Most of the places in the tests we were
already matching on error message, a couple of places we weren't. The
tick-tock one was the only one that wasn't being used right where it was
raised.

Some of them I just changed to RuntimeError because it was shorter than
adding the pylint directive.
2023-02-06 18:53:56 +13:00
toofar 2d66466194 Merge branch 'master' into qt6-v2
Just a few conflicts around CI and dependencies.
2022-11-20 15:48:00 +13:00
Florian Bruhin 1387c999fa Skip problematic QtWebKit tests with OpenSSL 3
See https://github.com/cherrypy/cheroot/issues/517 and #7467
2022-11-08 16:17:31 +01:00
Florian Bruhin 496c14bc9e quteprocess: Add --qute-delay-start
Allows for some rudimentary debugging of subprocesses.
2022-08-23 18:31:42 +02:00
Florian Bruhin 21d9c9a585 lint: Fix various small flake8 issues 2022-08-23 18:31:41 +02:00
Florian Bruhin de593e6a8c tests: Add some marks for Qt 5 / Qt 6 2022-08-23 18:31:41 +02:00
Florian Bruhin d387b1a108 tests: Adjust most imports 2022-08-23 18:31:40 +02:00
Florian Bruhin fc57a80ac8 Update YAML C extension check 2022-04-26 17:14:38 +02:00
Florian Bruhin 941627d778 Refactor tests to use new sandbox setting 2022-03-04 09:39:06 +01:00
Florian Bruhin 9c4169c7b7 tests: Remove some unused imports 2022-02-11 13:12:43 +01:00
Florian Bruhin c69cb057bc Rename --qute-bdd-backend and QUTE_BDD_BACKEND 2021-11-13 19:05:22 +01:00
Philipp Albrecht 437438d242 Add docstring to _select_backend() 2021-11-12 16:37:25 +01:00
Philipp Albrecht 256900b87a Extract backend selection into functions
In order to fix the issue of silently using QtWebEngine when e.g.
--qute-bdd-backend=webkit is given, even though QtWebEngine is not
available, I moved the selection logic into separate functions to
clear things up a little.

I tried to avoid the duplicate imports, in case the backend is
auto-selected, but after a while of thinking I abandoned that idea in
favor of moving forward with this.
2021-11-12 16:19:22 +01:00
Philipp Albrecht 59054e48b9 Use config.webengine in pytest_report_header() 2021-11-12 16:13:33 +01:00
Philipp Albrecht 5ea946277e Rename variable
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2021-11-12 14:48:28 +01:00
Philipp Albrecht a697e25094
Fix spelling
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2021-11-12 06:47:48 +01:00
Philipp Albrecht 8bb782332f Additionally report backend's version
To give more information we report the version additionally to the
backend's name.
2021-11-08 15:01:00 +01:00
Philipp Albrecht 7fcfb9b635 Enable overriding of backend auto-detection
One can override the auto-detection mechanism by passing
the backend via --qute-bdd-backend=<backend> or by setting the
environment variable QUTE_BDD_BACKEND=<backend>.
2021-11-05 15:50:41 +01:00
Philipp Albrecht 572ecd7fb1 Report backend in pytest_report_header() 2021-11-05 15:33:53 +01:00
Philipp Albrecht 53a1d45dd3 Consider auto-detection when setting config.webengine
Since config.webengine is widely used in the codebase, I decided to keep
it instead of replacing it entirely by using config.backend.
2021-11-05 15:33:53 +01:00
Philipp Albrecht 21055a39fc Set config.backend in pytest_configure()
For now this just serves the purpose of making the information available
to the pytest_report_header() hook, where we want to report, which
backend is used when running tests.
2021-11-05 15:30:02 +01:00