@@ -37,7 +37,7 @@ module.exports = {
3737 emulatorProcessIdentifier : args . emulatorProcessIdentifier ,
3838 modulesPath : args . modulesPath || "./bin/dist/tns-core-modules-" + modulesPackageConfig . version + ".tgz" ,
3939 emuAvdName : args . emuAvdName ,
40- outfile : args . outFile || "./TestRunResult.txt" ,
40+ outFile : args . outFile || "./TestRunResult.txt" ,
4141 frameworkArgument : args . runtimePath ? " --frameworkPath=" + args . runtimePath : "" ,
4242 showEmu : args . showEmu || false ,
4343
@@ -50,7 +50,7 @@ module.exports = {
5050 deployedAppName :"org.nativescript.TestsApp" ,
5151 mainActivityName :"com.tns.NativeScriptActivity" ,
5252 pathToCompiledTests : "bin/dist/apps/tests" ,
53-
53+ simulatorSysLog : pathModule . join ( process . env . HOME , "Library/Logs/CoreSimulator" , args . emuAvdName , "/system.log" ) ,
5454 platform : args . platform
5555 }
5656
@@ -70,6 +70,12 @@ module.exports = {
7070 } ,
7171 tempExtractedModules : {
7272 src : pathModule . join ( localCfg . applicationDir , "node_modules" , "package" )
73+ } ,
74+ simulatorLog : {
75+ src : localCfg . simulatorSysLog ,
76+ options : {
77+ force : true
78+ }
7379 }
7480 } ,
7581 mkdir : {
@@ -134,6 +140,10 @@ module.exports = {
134140 return newContent ;
135141 }
136142 }
143+ } ,
144+ simulatorLog : {
145+ src : localCfg . simulatorSysLog ,
146+ dest : localCfg . outFile
137147 }
138148 } ,
139149 exec : {
@@ -163,6 +173,9 @@ module.exports = {
163173 cmd : "adb install " + localCfg . pathToApk ,
164174 cwd : localCfg . applicationDir
165175 } ,
176+ startAndroidEmulator : {
177+ cmd : "emulator -avd " + localCfg . emuAvdName + " -no-audio " + ( args . showEmu ? "" : "-no-window" ) + "&"
178+ } ,
166179 startAndroidApp : {
167180 cmd : "adb shell am start -n " + localCfg . deployedAppName + "/" + localCfg . mainActivityName
168181 } ,
@@ -186,17 +199,22 @@ module.exports = {
186199 } ,
187200 shell : {
188201 collectAndroidLog : {
189- command : "./expect.exp " + localCfg . outfile ,
202+ command : "./expect.exp " + "'adb logcat' " + localCfg . outFile ,
190203 options : {
191204 execOptions : {
192205 maxBuffer : Infinity
193206 }
194207 }
195208 } ,
196- startAndroidEmulator : {
197- command : "emulator -avd " + localCfg . emuAvdName + " -no-audio " + ( args . showEmu ? "" : "-no-window" ) + "&"
209+ waitiOSLogCompletion : {
210+ command : "./expect.exp " + "'tail -f " + localCfg . simulatorSysLog + "' " + localCfg . outFile ,
211+ options : {
212+ execOptions : {
213+ maxBuffer : Infinity
214+ }
215+ }
198216 } ,
199- startiOSEmulator : {
217+ startiOSSimulator : {
200218 command : "xcrun instruments -w " + localCfg . emuAvdName ,
201219 options : {
202220 failOnError : false
@@ -225,38 +243,57 @@ module.exports = {
225243 return templatedTaskName . replace ( / \{ p l a t f o r m \} / , localCfg . platform ) ;
226244 }
227245
246+ grunt . registerTask ( "startEmulatorAndroid" , [
247+ getPlatformSpecificTask ( "exec:startAndroidEmulator" ) ,
248+ ] ) ;
249+
250+ grunt . registerTask ( "startEmulatoriOS" , [
251+ getPlatformSpecificTask ( "shell:startiOSSimulator" ) ,
252+ ] ) ;
253+
254+ grunt . registerTask ( "collectLogAndroid" , [
255+ "shell:collectAndroidLog"
256+ ] ) ;
257+
258+ grunt . registerTask ( "collectLogiOS" , [
259+ "shell:waitiOSLogCompletion" ,
260+ "copy:simulatorLog"
261+ ] ) ;
262+
228263 grunt . registerTask ( "doPostPlatformAddAndroid" , [
229- "exec:restartAdb"
230- ] ) ;
264+ "exec:restartAdb"
265+ ] ) ;
266+
231267 grunt . registerTask ( "doPostPlatformAddiOS" , [
232- ] ) ;
268+ "clean:simulatorLog"
269+ ] ) ;
233270
234271
235272//xcrun instruments -s
236273 grunt . registerTask ( "testsapp" , [
237- // "clean:workingDir",
238- // "mkdir:workingDir",
239- // getPlatformSpecificTask("exec:kill{platform}Emulator"),
240- // getPlatformSpecificTask("shell:start {platform}Emulator "),
241- //
242- // "exec:createApp",
243- // "clean:originalAppDir",
244- // "copy:testsAppToRunDir",
245- // "clean:modules",
246- // "untar:modules",
247- // "copy:modulesToDir",
248- // "clean:tempExtractedModules",
249- //
250- // "exec:addPlatform",
251- // getPlatformSpecificTask("copy:add{platform}Permissions"),
252- // "shell:buildApp",
253- // getPlatformSpecificTask("doPostPlatformAdd{platform}"),
274+ "clean:workingDir" ,
275+ "mkdir:workingDir" ,
276+ getPlatformSpecificTask ( "exec:kill{platform}Emulator" ) ,
277+ getPlatformSpecificTask ( "startEmulator {platform}" ) ,
278+
279+ "exec:createApp" ,
280+ "clean:originalAppDir" ,
281+ "copy:testsAppToRunDir" ,
282+ "clean:modules" ,
283+ "untar:modules" ,
284+ "copy:modulesToDir" ,
285+ "clean:tempExtractedModules" ,
286+
287+ "exec:addPlatform" ,
288+ getPlatformSpecificTask ( "copy:add{platform}Permissions" ) ,
289+ "shell:buildApp" ,
290+ getPlatformSpecificTask ( "doPostPlatformAdd{platform}" ) ,
254291
255292 getPlatformSpecificTask ( "exec:uninstallExisting{platform}App" ) ,
256293 getPlatformSpecificTask ( "exec:installNew{platform}App" ) ,
257294 getPlatformSpecificTask ( "exec:start{platform}App" ) ,
258- // getPlatformSpecificTask("shell:collect {platform}Log "),
259- //
295+ getPlatformSpecificTask ( "collectLog {platform}" ) ,
296+
260297// getPlatformSpecificTask("exec:kill{platform}Emulator"),
261298// "clean:workingDir"
262299 ] ) ;
0 commit comments