scripting: Allow avoiding exiting perf helper
This will help creating test cases where windows are open during shutdown. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2722>
This commit is contained in:
parent
ff705fa902
commit
2325022d2f
@ -1,7 +1,7 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported sleep, waitLeisure, createTestWindow, waitTestWindows,
|
||||
destroyTestWindows, defineScriptEvent, scriptEvent,
|
||||
collectStatistics, runPerfScript */
|
||||
collectStatistics, runPerfScript, disableHelperAutoExit */
|
||||
|
||||
const { Gio, GLib, Meta, Shell } = imports.gi;
|
||||
|
||||
@ -70,8 +70,10 @@ function PerfHelper() {
|
||||
|
||||
let _perfHelper = null;
|
||||
function _getPerfHelper() {
|
||||
if (_perfHelper == null)
|
||||
if (_perfHelper == null) {
|
||||
_perfHelper = new PerfHelper();
|
||||
_perfHelper._autoExit = true;
|
||||
}
|
||||
|
||||
return _perfHelper;
|
||||
}
|
||||
@ -140,6 +142,17 @@ function destroyTestWindows() {
|
||||
perfHelper.DestroyWindowsAsync().catch(logError);
|
||||
}
|
||||
|
||||
/**
|
||||
* disableHelperAutoExit:
|
||||
*
|
||||
* Don't exixt the perf helper after running the script. Instead it will remain
|
||||
* running until something else makes it exit, e.g. the Wayland socket closing.
|
||||
*/
|
||||
function disableHelperAutoExit() {
|
||||
let perfHelper = _getPerfHelper();
|
||||
perfHelper._autoExit = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* defineScriptEvent
|
||||
* @param {string} name: The event will be called script.<name>
|
||||
@ -287,6 +300,7 @@ async function _runPerfScript(scriptModule, outputFile) {
|
||||
|
||||
try {
|
||||
const perfHelper = _getPerfHelper();
|
||||
if (perfHelper._autoExit)
|
||||
perfHelper.ExitSync();
|
||||
} catch (err) {
|
||||
log(`Failed to exit helper: ${err}\n${err.stack}`);
|
||||
|
Loading…
Reference in New Issue
Block a user