From 52cff12c384fd1081f6bc2ed3b34cb0a7ee0697a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Jun 2024 19:21:07 +0200 Subject: [PATCH] [displaymanager] Repair test for gdm3 This was intended to check code for obvious logical failures, but also stops tests because the gdm paths don't exist. For testing purposes, create bogus gdm3 executable in the "target" tempdir. --- .../displaymanager/tests/test-dm-gdm.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/displaymanager/tests/test-dm-gdm.py b/src/modules/displaymanager/tests/test-dm-gdm.py index 778bb8fbb..4856e8af3 100644 --- a/src/modules/displaymanager/tests/test-dm-gdm.py +++ b/src/modules/displaymanager/tests/test-dm-gdm.py @@ -10,10 +10,17 @@ libcalamares.globalstorage.insert("testing", True) from src.modules.displaymanager import main default_desktop_environment = main.DesktopEnvironment("startplasma-x11", "kde-plasma.desktop") -# Specific DM test -d = main.DMgdm("/tmp") -d.have_dm() -d.set_autologin("d", True, default_desktop_environment) -# .. and again (this time checks load/save) -d.set_autologin("d", True, default_desktop_environment) -d.set_autologin("d", True, default_desktop_environment) +import os +import tempfile +with tempfile.TemporaryDirectory(prefix="calamares-gdm") as tempdir: + os.makedirs(tempdir + "/usr/bin") + os.makedirs(tempdir + "/etc/gdm3") + with open(tempdir + "/usr/bin/gdm3", "w") as f: + f.write("#! /bin/sh\n:\n") + # Specific DM test + d = main.DMgdm(tempdir) + assert(d.have_dm()) + d.set_autologin("d", True, default_desktop_environment) + # .. and again (this time checks load/save) + d.set_autologin("d", True, default_desktop_environment) + d.set_autologin("d", True, default_desktop_environment)