virt-manager: Add --test-options gsettings-keyfile
This will let us test some difficult code paths in the uitests. Rework the `--test-options first-run` behavior to use a temporary keyfile rather than the memory backend, to unify the code paths Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
a121c943ef
commit
8dd3b8ba20
|
@ -47,16 +47,23 @@ class _SettingsWrapper(object):
|
|||
we internally convert it to the settings nested hierarchy. Makes
|
||||
client code much smaller.
|
||||
"""
|
||||
def __init__(self, settings_id):
|
||||
def __init__(self, settings_id, gsettings_keyfile):
|
||||
self._root = settings_id
|
||||
self._settings = Gio.Settings.new(self._root)
|
||||
|
||||
if gsettings_keyfile:
|
||||
backend = Gio.keyfile_settings_backend_new(gsettings_keyfile, "/")
|
||||
else:
|
||||
backend = Gio.SettingsBackend.get_default()
|
||||
|
||||
self._settings = Gio.Settings.new_with_backend(self._root, backend)
|
||||
|
||||
self._settingsmap = {"": self._settings}
|
||||
self._handler_map = {}
|
||||
|
||||
for child in self._settings.list_children():
|
||||
childschema = self._root + "." + child
|
||||
self._settingsmap[child] = Gio.Settings.new(childschema)
|
||||
self._settingsmap[child] = Gio.Settings.new_with_backend(
|
||||
childschema, backend)
|
||||
|
||||
|
||||
###################
|
||||
|
@ -189,7 +196,8 @@ class vmmConfig(object):
|
|||
self.conf_dir = "/org/virt-manager/%s/" % self.appname
|
||||
self.ui_dir = BuildConfig.ui_dir
|
||||
|
||||
self.conf = _SettingsWrapper("org.virt-manager.virt-manager")
|
||||
self.conf = _SettingsWrapper("org.virt-manager.virt-manager",
|
||||
CLITestOptions.gsettings_keyfile)
|
||||
|
||||
self.CLITestOptions = CLITestOptions
|
||||
if self.CLITestOptions.xmleditor_enabled:
|
||||
|
|
|
@ -200,15 +200,29 @@ class CLITestOptionsClass:
|
|||
opts.remove(optname)
|
||||
return True
|
||||
|
||||
def _get_value(optname):
|
||||
for opt in opts:
|
||||
if opt.startswith(optname + "="):
|
||||
opts.remove(opt)
|
||||
return opt.split("=", 1)[1]
|
||||
|
||||
self.first_run = _get("first-run")
|
||||
self.leak_debug = _get("leak-debug")
|
||||
self.no_events = _get("no-events")
|
||||
self.xmleditor_enabled = _get("xmleditor-enabled")
|
||||
self.gsettings_keyfile = _get_value("gsettings-keyfile")
|
||||
|
||||
if opts:
|
||||
print("Unknown --test-options keys: %s" % opts)
|
||||
sys.exit(1)
|
||||
|
||||
if self.first_run and not self.gsettings_keyfile:
|
||||
import atexit
|
||||
import tempfile
|
||||
filename = tempfile.mktemp(prefix="virtmanager-firstrun-keyfile")
|
||||
self.gsettings_keyfile = filename
|
||||
atexit.register(lambda: os.unlink(filename))
|
||||
|
||||
|
||||
def main():
|
||||
(options, leftovers) = parse_commandline()
|
||||
|
|
Loading…
Reference in New Issue