Skip to content

Commit

Permalink
Kill CoreSimulatorService when timing out
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Heilner committed May 4, 2016
1 parent 6bdad07 commit ce8c2f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Runner/DeviceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,33 @@ class DeviceController {
return processString.componentsSeparatedByString(" ").filter { !$0.trimmed().isEmpty }
}

func killCoreSimulatorService() {
let task = NSTask()
task.launchPath = "/bin/sh"
task.arguments = ["-c", "ps aux | grep CoreSimulatorService"]

let standardOutputData = NSMutableData()
let pipe = NSPipe()
pipe.fileHandleForReading.readabilityHandler = { handle in
standardOutputData.appendData(handle.availableData)
}
task.standardOutput = pipe
task.launch()
task.waitUntilExit()

print("KILLING CoreSimulatorService")

if task.terminationStatus == 0, let processInfoString = String(data: standardOutputData, encoding: NSUTF8StringEncoding) {
for processString in processInfoString.componentsSeparatedByString("\n") {
let parts = getProcessComponents(processString)
if !parts.isEmpty && !parts.contains("grep") {
killProcess(parts)
}
}
}
}


func killProcessesForDevice(deviceID: String) {
let task = NSTask()
task.launchPath = "/bin/sh"
Expand Down
2 changes: 2 additions & 0 deletions Runner/TestRunnerOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class TestRunnerOperation: NSOperation {
TRLog(data, simulatorName: self.simulatorName)
}

DeviceController.sharedController.killCoreSimulatorService()

self.loaded = true
NSNotificationCenter.defaultCenter().postNotificationName(TestRunnerOperationQueue.SimulatorLoadedNotification, object: nil)
return
Expand Down

0 comments on commit ce8c2f9

Please sign in to comment.