Skip to content

ui, tests: isolate HOME and XDG dirs from the real installation - #1678

Open
aadrian wants to merge 1 commit into
evilsocket:masterfrom
aadrian:tests-isolate-home
Open

aadrian wants to merge 1 commit into
evilsocket:masterfrom
aadrian:tests-isolate-home

Conversation

@aadrian

@aadrian aadrian commented Oct 5, 2026

Copy link
Copy Markdown

Running the UI tests on a machine where OpenSnitch is installed changes the settings of that installation:

  • test_preferences.py deletes ~/.config/opensnitch/settings.conf, and the dialogs then rewrite it through QSettings("opensnitch", "settings").
  • Pressing Apply in the preferences tests calls Autostart.enable(). That can create or remove ~/.config/autostart/opensnitch_ui.desktop, or add Hidden=true to it, which turns off autostart of the installed UI.

I noticed this after a local test run reset the settings of the UI I was running.

This PR only changes ui/tests/conftest.py:

  • HOME and XDG_* point to a temporary directory. It is set up before opensnitch is imported, because utils/xdg.py reads these variables at import time. DBUS_SESSION_BUS_ADDRESS is unset, so no notification reaches the desktop.
  • A session fixture fails if the settings, autostart or runtime paths resolve outside that directory. It also fails if the real settings.conf or autostart file changed during the run.

Tested:

Several open PRs add or change UI tests (#1650, #1614, #1578, ...). Merging this first would keep anyone who runs them locally from losing their settings.

The preferences tests delete ~/.config/opensnitch/settings.conf and write
it through QSettings, and pressing Apply calls Autostart.enable(), which
can create, remove or hide ~/.config/autostart/opensnitch_ui.desktop.
Running the suite on a machine with OpenSnitch installed therefore
replaced the user's real UI settings.

Redirect HOME and the XDG dirs to a temporary directory before opensnitch
is imported (utils/xdg.py caches the paths at import time), and add a
session fixture that fails if the paths resolve outside of it or if the
real settings.conf or autostart file changed during the run.
@aadrian

aadrian commented Oct 5, 2026

Copy link
Copy Markdown
Author

@gustavo-iniguez-goya in case it helps with 1.9.0: these four open PRs fix things that break the UI or the package builds on a clean install. Each is small and based on master.

Thanks in advance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant