Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AutotestRunner.c
Go to the documentation of this file.
1
14
sealed
class
SCR_TestRunner
15
{
16
//------------------------------------------------------------------------------------------------
17
static
bool
ShouldCreate()
18
{
19
HandleCommandLineArguments();
20
21
bool
shouldCreate =
SCR_AutotestHarness
.
s_bIsRunning
;
22
if
(!shouldCreate)
23
{
24
return
false
;
25
}
26
27
Print
(
"Creating: SCR_TestRunner"
,
LogLevel
.NORMAL);
28
29
return
true
;
30
}
31
32
//------------------------------------------------------------------------------------------------
33
private
static
void
HandleCommandLineArguments()
34
{
35
bool
autotestParamPresent =
System
.IsCLIParam(
"autotest"
);
36
if
(!autotestParamPresent)
37
return
;
38
39
string
autotestConfigCLI;
40
System
.GetCLIParam(
"autotest"
, autotestConfigCLI);
41
42
if
(!autotestConfigCLI)
43
{
44
Debug
.Error(
"Empty -autotest parameter value"
);
45
GetGame
().RequestClose();
46
}
47
48
if
(autotestConfigCLI.StartsWith(
"{"
))
49
{
50
Resource
configHolder =
Resource
.Load(autotestConfigCLI);
51
if
(configHolder.IsValid())
52
{
53
SCR_AutotestGroup
config =
SCR_AutotestGroup
.Cast(
BaseContainerTools
.CreateInstanceFromContainer(configHolder.GetResource().ToBaseContainer()));
54
if
(config)
55
{
56
PrintFormat
(
"CLI autotest config: %1"
, config, level:
LogLevel
.NORMAL);
57
SCR_AutotestHarness
.
Begin
(config,
true
);
58
return
;
59
}
60
61
PrintFormat
(
"Specified resource is not of type SCR_AutotestGroup: %1"
, config, level:
LogLevel
.ERROR);
62
}
63
else
64
{
65
PrintFormat
(
"Invalid resource path for autotest config: %1"
, autotestConfigCLI, level:
LogLevel
.ERROR);
66
}
67
}
68
69
if
(autotestConfigCLI.ToType().IsInherited(
SCR_AutotestSuiteBase
))
70
{
71
PrintFormat
(
"CLI autotest suite: %1"
, autotestConfigCLI, level:
LogLevel
.NORMAL);
72
SCR_AutotestSuiteBase
testSuite =
SCR_AutotestSuiteBase
.Cast(autotestConfigCLI.ToType().Spawn());
73
SCR_AutotestHarness
.
Begin
(testSuite,
true
);
74
return
;
75
}
76
77
if
(autotestConfigCLI.ToType().IsInherited(
SCR_AutotestCaseBase
))
78
{
79
PrintFormat
(
"CLI autotest case: %1"
, autotestConfigCLI, level:
LogLevel
.NORMAL);
80
SCR_AutotestCaseBase
testCase =
SCR_AutotestCaseBase
.Cast(autotestConfigCLI.ToType().Spawn());
81
SCR_AutotestHarness
.
Begin
(testCase,
true
);
82
return
;
83
}
84
85
Debug
.Error(
string
.Format(
"Invalid -autotest parameter value: %1"
, autotestConfigCLI));
86
GetGame
().RequestClose();
87
}
88
89
//------------------------------------------------------------------------------------------------
90
void
OnUpdate
(notnull
Game
game
)
91
{
92
if
(!
SCR_AutotestHarness
.
s_bIsRunning
)
93
return
;
94
95
if
(
GameStateTransitions
.IsTransitionRequestedOrInProgress())
96
return
;
97
98
if
(!
game
.IsPreloadFinished())
99
return
;
100
101
#ifdef ENABLE_DIAG
102
if
(
DiagMenu
.GetBool(
SCR_DebugMenuID
.DEBUGUI_AUTOTEST_PROGRESS,
true
))
103
SCR_AutotestDebugMenu.GetInstance().Update();
104
#endif
105
106
// execute the tests
107
if
(!
SCR_AutotestHarness
.Run())
108
return
;
109
110
Print
(
"SCR_TestRunner has finished running"
,
LogLevel
.NORMAL);
111
112
SCR_AutotestReport
report =
SCR_AutotestHarness
.Finish();
113
report.
WriteJUnitXML
();
114
report.
WriteFailedList
();
115
116
#ifdef ENABLE_DIAG
117
SCR_AutotestDebugMenu.Terminate();
118
#endif
119
120
if
(ShouldCloseGameAfterRun())
121
{
122
// GameStateTransitions.RequestGameTerminateTransition();
123
GetGame
().RequestClose();
124
}
125
}
126
127
//------------------------------------------------------------------------------------------------
128
void
Abort(notnull
Game
game
)
129
{
130
#ifdef WORKBENCH
131
// on game end is called two times when going back to EditorMode
132
// on the first call InPlayMode is true, false on second
133
if
(!
game
.InPlayMode() &&
SCR_AutotestHarness
.
s_bIsRunning
)
134
SCR_AutotestHarness
.Finish(abort:
true
);
135
#endif
136
}
137
138
//------------------------------------------------------------------------------------------------
139
private
bool
ShouldCloseGameAfterRun()
140
{
141
return
SCR_AutotestHarness
.
s_bCloseGameAfterRun
;
142
}
143
}
game
ref DSGameConfig game
Definition
DSConfig.c:81
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition
DebugMenuID.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
OnUpdate
override void OnUpdate()
Definition
SCR_MapMarkerSquadLeader.c:333
BaseContainerTools
Definition
BaseContainerTools.c:13
Debug
Definition
Debug.c:13
DiagMenu
Diagnostic and developer menu system.
Definition
DiagMenu.c:18
Game
Definition
Game.c:8
GameStateTransitions
Definition
GameStateTransitions.c:13
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
SCR_AutotestCaseBase
Definition
SCR_AutotestCaseBase.c:6
SCR_AutotestGroup
Collection of test suites.
Definition
SCR_AutotestGroup.c:4
SCR_AutotestHarness
Definition
SCR_AutotestHarness.c:24
SCR_AutotestHarness::s_bIsRunning
static bool s_bIsRunning
Definition
SCR_AutotestHarness.c:30
SCR_AutotestHarness::Begin
static void Begin(SCR_AutotestGroup testGroup, bool autorun=false, bool verboseLog=false)
Configures the test runner to execute only the test suites present in the specified test group and in...
Definition
SCR_AutotestHarness.c:57
SCR_AutotestHarness::s_bCloseGameAfterRun
static bool s_bCloseGameAfterRun
Definition
SCR_AutotestHarness.c:33
SCR_AutotestReport
Definition
SCR_AutotestReport.c:3
SCR_AutotestReport::WriteFailedList
void WriteFailedList()
Definition
SCR_AutotestReport.c:34
SCR_AutotestReport::WriteJUnitXML
void WriteJUnitXML()
Definition
SCR_AutotestReport.c:24
SCR_AutotestSuiteBase
Definition
SCR_AutotestSuiteBase.c:8
SCR_TestRunner
Definition
SCR_AutotestRunner.c:15
System
Definition
System.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
PrintFormat
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)
scripts
Autotest
Game
TestFramework
SCR_AutotestRunner.c
Generated by
1.17.0