Skip to content

Commit

Permalink
Run tests just on the session bus
Browse files Browse the repository at this point in the history
Avoid the system bus, since otherwise needs roots permissions, and is
more cumbersome to setup
  • Loading branch information
pabloyoyoista committed Oct 2, 2023
1 parent b00c274 commit 7ea573d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}

- name: Build and test plugin
run: docker run --mount type=bind,src=${{ github.workspace }},dst=/repo --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:${{ env.VERSION}} /bin/ash -c "cd repo && meson build && ninja -C build && dbus-daemon --system --fork --nopidfile && dbus-run-session -- meson test -v -C build"
run: docker run --mount type=bind,src=${{ github.workspace }},dst=/repo --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:${{ env.VERSION}} /bin/ash -c "cd repo && meson build && ninja -C build && dbus-run-session -- meson test -v -C build"

- name: Push Docker image
if: github.event_name == 'push'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
run: meson build && ninja -C build

- name: Test
run: dbus-daemon --system --fork --nopidfile && dbus-run-session -- meson test -v -C build
run: dbus-run-session -- meson test -v -C build
5 changes: 4 additions & 1 deletion src/gs-plugin-apk/gs-plugin-apk.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,16 @@ gs_plugin_apk_setup_async (GsPlugin *plugin,
gpointer user_data)
{
g_autoptr (GTask) task = NULL;
GBusType bus_type = G_BUS_TYPE_SYSTEM;

task = g_task_new (plugin, cancellable, callback, user_data);
g_task_set_source_tag (task, gs_plugin_apk_setup_async);

g_debug ("Initializing plugin");

apk_polkit2_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
if (g_getenv ("G_TEST_SRCDIR"))
bus_type = G_BUS_TYPE_SESSION;
apk_polkit2_proxy_new_for_bus (bus_type,
G_DBUS_PROXY_FLAGS_NONE,
"dev.Cogitri.apkPolkit2",
"/dev/Cogitri/apkPolkit2",
Expand Down
2 changes: 1 addition & 1 deletion tests/apkpolkit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
BUS_NAME = 'dev.Cogitri.apkPolkit2'
MAIN_OBJ = '/dev/Cogitri/apkPolkit2'
MAIN_IFACE = 'dev.Cogitri.apkPolkit2'
SYSTEM_BUS = True
SYSTEM_BUS = False

def load(mock, parameters):
repos = [
Expand Down
3 changes: 3 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def setUp(self):
def tearDown(self):
if self.log is not None:
self.log.close()
if self.p_mock:
self.p_mock.terminate()
self.p_mock.wait()

def test_apk(self):
builddir = os.getenv('G_TEST_BUILDDIR')
Expand Down

0 comments on commit 7ea573d

Please sign in to comment.