-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify get simulator command + reduce launch time #31
Conversation
@@ -8,7 +8,7 @@ class TagsController { | |||
if let launchPath = Constants.FilePaths.Bash.tags { | |||
let outputStream = CommandsCore.CommandTextOutputStream() | |||
outputStream.textHandler = {text in | |||
tags.append(contentsOf: text.components(separatedBy: "\n")) | |||
tags.append(contentsOf: text.components(separatedBy: "\n").filter { !$0.isEmpty }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@q231950 Not sure why it is needed. Sometimes we get a lot of empty strings after actual result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess somewhere in the script an empty line is generated.
PR is ready to be reviewed ;) @BasThomas @q231950 |
Uh-oh: it seems to be crashing locally:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments. How can I test your changes?
if let launchPath = Constants.FilePaths.Bash.startDevice { | ||
let outputStream = CommandsCore.CommandTextOutputStream() | ||
outputStream.textHandler = { text in | ||
if !text.isEmpty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe make this guard !text.isEmpty else { return }
to prevent some indentation?
arguments = [phoneUDID] | ||
} | ||
DispatchQueue.global(qos: .background).async { | ||
self.commands.executeCommand(at: launchPath, arguments: arguments, outputStream: outputStream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this run on a background thread (but eg. https://github.com/JoeSSS/calabash-launcher/pull/31/files#diff-8622fb2ab735c45bc8f54aee4b135938R223 isn't?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some methods like running tests or this one that takes a lot of time to continue. If I do it in the main thread, it will freeze the whole APP, but we actually can use the APP while these commands are executing in background
@IBOutlet var get_device: NSButtonCell! | ||
@IBOutlet var simulatorRadioButton: NSButton! | ||
@IBOutlet var physicalDeviceRadioButton: NSButton! | ||
@IBOutlet var getDeviceButton: NSButtonCell! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
let applicationStateHandler = ApplicationStateHandler() | ||
let tagsController = TagsController() | ||
let fileManager = FileManager.default | ||
var devices: [String] = [""] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe either remove the : [String]
or make the initial array empty ([]
)
killProcessesProcess.launch() | ||
killProcessesProcess.waitUntilExit() | ||
} | ||
commands.executeCommand(at: Constants.FilePaths.Bash.killProcess ?? "", arguments: [""]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the empty argument?
if let launchPath = Constants.FilePaths.Bash.sendToIRB { | ||
let outputStream = CommandsCore.CommandTextOutputStream() | ||
outputStream.textHandler = { text in | ||
if !text.isEmpty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guard !text.isEmpty else { return }
} | ||
} | ||
} | ||
let arguments = [self.textField.stringValue] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's declare this inside the handler.
} | ||
} | ||
commands.executeCommand(at: launchPath, arguments: [""], outputStream: outputStream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[]
?
strongSelf.generalIRBSessionTask.launch() | ||
strongSelf.generalIRBSessionTask.waitUntilExit() | ||
} | ||
commands.executeCommand(at: Constants.FilePaths.Bash.quitIRBSession ?? "", arguments: [""]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[]
@@ -584,14 +427,16 @@ class TasksViewController: NSViewController { | |||
self.textViewPrinter.printToTextView(text) | |||
} | |||
} | |||
let commands = CommandsCore.CommandExecutor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, let's create a ticket for this: we should remove the runScript
from the VC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus track: Kill all processes by moving everything to CommandsCore