protected void waitForTaskEnd(TaskListenerFlag flag) {
		waitForSwing();

		int totalTime = 0;
		while (!flag.ended && totalTime <= GUI_RUN_SCRIPT_TIMEOUT_MSECS) {
			totalTime += sleep(DEFAULT_WAIT_DELAY);
		}

		TaskUtilities.removeTrackedTaskListener(flag);

		if (!flag.ended) {
			Assert.fail("Task took too long to complete: " + flag);
		}
		Msg.debug(this, flag.taskName + " task ended in " + totalTime + " ms");
	}
Run the last script by pressing the last script button and return output.

@param taskName name for the task listener
@return script output written to the console
@throws Exception on failure, e.g. timeout
Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/script/AbstractGhidraScriptMgrPluginTest.java