@@ -19,10 +19,12 @@ package wooga.gradle.unity
19
19
20
20
import com.wooga.gradle.PlatformUtils
21
21
import com.wooga.gradle.test.IntegrationSpec
22
- import com.wooga.gradle.test.executable.FakeExecutables
22
+ import com.wooga.gradle.test.mock.MockExecutable
23
23
import com.wooga.spock.extensions.unity.DefaultUnityPluginTestOptions
24
24
import com.wooga.spock.extensions.unity.UnityPathResolution
25
25
import com.wooga.spock.extensions.unity.UnityPluginTestOptions
26
+ import groovy.transform.stc.ClosureParams
27
+ import groovy.transform.stc.FromString
26
28
import wooga.gradle.unity.tasks.Unity
27
29
import wooga.gradle.unity.utils.ProjectSettingsFile
28
30
@@ -100,8 +102,9 @@ abstract class UnityIntegrationSpec extends IntegrationSpec {
100
102
101
103
switch (options. unityPath()) {
102
104
case UnityPathResolution.Mock :
103
- mockUnityFile = createMockUnity()
104
- addUnityPathToExtension(mockUnityFile. path)
105
+ if (options. writeMockExecutable()) {
106
+ writeMockExecutable()
107
+ }
105
108
break
106
109
107
110
case UnityPathResolution.Default :
@@ -132,6 +135,24 @@ abstract class UnityIntegrationSpec extends IntegrationSpec {
132
135
projectSettingsFile
133
136
}
134
137
138
+ /**
139
+ * Writes the mock executable with a predetermined location
140
+ */
141
+ protected void writeMockExecutable (@ClosureParams (value = FromString , options = " com.wooga.gradle.test.mock.MockExecutable" )
142
+ Closure<MockExecutable > configure = null ) {
143
+ // Create and configure the file to be written
144
+ def mockUnity = new MockExecutable (" fakeUnity.bat" )
145
+ mockUnity. withText(mockUnityStartupMessage)
146
+ if (configure != null ) {
147
+ configure(mockUnity)
148
+ }
149
+ // Write the file
150
+ mockUnityFile = mockUnity. toDirectory(unityMainDirectory)
151
+ // Write its location onto the unity extension
152
+ addUnityPathToExtension(mockUnityFile. path)
153
+ }
154
+
155
+ // TODO: Refactor away
135
156
protected File createMockUnity (String extraLog = null , int exitValue = 0 ) {
136
157
def mockUnityFile = createFile(" fakeUnity.bat" , unityMainDirectory). with {
137
158
delete()
@@ -165,7 +186,6 @@ abstract class UnityIntegrationSpec extends IntegrationSpec {
165
186
""" . readLines(). collect{it. stripIndent(). trim() }. findAll {! it. empty}. join(" \n " )
166
187
}
167
188
return mockUnityFile
168
-
169
189
}
170
190
171
191
void setLicenseDirectory () {
0 commit comments