2[WorkbenchToolAttribute(
5 awesomeFontCode: 0xF188
7class SCR_AutotestTool : WorldEditorTool
10 protected ResourceName m_sTestGroup;
12 [
Attribute(
"", UIWidgets.EditBox,
category:
"Test Selection",
desc:
"Name of test case or test suite class to execute.")]
13 protected string m_sTestClass;
15 [
Attribute(
"", UIWidgets.CheckBox,
category:
"New Process",
desc:
"Should the tests run in new process.")]
16 protected bool m_bRunInNewWindow;
18 [
Attribute(SCR_AutotestHelper.GetDefaultLaunchParams(), UIWidgets.EditBoxMultiline,
category:
"New Process",
desc:
"Additional arguments the new process will launch with.")]
19 protected string m_bArguments;
21 protected ScriptEditor m_ScriptEditor = Workbench.GetModule(ScriptEditor);
25 protected void ButtonRunGroup()
29 SCR_AutotestGroup config = GetConfigByPath(m_sTestGroup);
35 if (m_bRunInNewWindow)
37 RunNewProcess(m_sTestGroup);
41 SCR_AutotestPlugin autotestPlugin = SCR_AutotestPlugin.Cast(m_ScriptEditor.GetPlugin(SCR_AutotestPlugin));
42 autotestPlugin.FocusWorldEditor();
44 autotestPlugin.RunConfig(config);
49 protected void ButtonRunClass()
51 if (m_bRunInNewWindow)
53 RunNewProcess(m_sTestClass);
57 SCR_AutotestPlugin autotestPlugin = SCR_AutotestPlugin.Cast(m_ScriptEditor.GetPlugin(SCR_AutotestPlugin));
58 autotestPlugin.FocusWorldEditor();
60 autotestPlugin.RunClassName(m_sTestClass.Trim(),
true);
64 protected SCR_AutotestGroup GetConfigByPath(ResourceName configName)
66 Resource configHolder = Resource.Load(configName);
68 return SCR_AutotestGroup.Cast(BaseContainerTools.CreateInstanceFromContainer(configHolder.GetResource().ToBaseContainer()));
72 protected void RunNewProcess(
string autotestArg)
75 Workbench.GetCwd(cwd);
77 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
78 SCR_AutotestToolPlugin settings = SCR_AutotestToolPlugin.Cast(worldEditor.GetPlugin(SCR_AutotestToolPlugin));
80 string exePath = settings.GetExecutablePath();
83 Workbench.Dialog(
"Autotest Tool - Error",
"Executable path not configured.\nPlugins > Settings > Autotest Tool");
88 string gproj = Workbench.GetCurrentGameProjectFile();
90 string cmd =
string.Format(
"\"%1\" -gproj \"%2\"", exe, gproj);
92 string addonDirs = GetAddonsDirCLI();
93 cmd +=
string.Format(
" -addonsDir %1", addonDirs);
95 string addons = GetAddonsCLI();
96 cmd +=
string.Format(
" -addons %1", addons);
98 cmd +=
string.Format(
" -autotest %1", autotestArg);
101 cmd +=
" " + m_bArguments;
104 ProcessHandle handle = Workbench.RunProcess(cmd);
106 Print(
"Autotest couldn't run. Check if your Executable or other settings are correct",
LogLevel.ERROR);
110 protected string GetAddonsDirCLI()
113 array<string> addonsGUIDs = {};
114 GameProject.GetLoadedAddons(addonsGUIDs);
116 foreach (
string GUID : addonsGUIDs)
118 if (!GameProject.IsVanillaAddon(GUID))
120 string addonPath =
"$" + GameProject.GetAddonID(GUID) +
":";
122 if (Workbench.GetAbsolutePath(addonPath, absPath))
124 if (!addonsDir.IsEmpty())
127 addonsDir += absPath;
132 return "\"" + addonsDir +
"\"";
136 protected string GetAddonsCLI()
140 array<string> addonsGUIDs = {};
141 GameProject.GetLoadedAddons(addonsGUIDs);
143 foreach (
string GUID : addonsGUIDs)
145 if (!GameProject.IsVanillaAddon(GUID))
147 if (!addonIDs.IsEmpty())
150 addonIDs += GameProject.GetAddonID(GUID);
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute