Skip to content
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

Merged
merged 11 commits into from
Oct 23, 2017
Merged

Conversation

JoeSSS
Copy link
Contributor

@JoeSSS JoeSSS commented Oct 20, 2017

Bonus track: Kill all processes by moving everything to CommandsCore

@JoeSSS JoeSSS requested review from q231950 and BasThomas October 20, 2017 20:33
@@ -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 })
Copy link
Contributor Author

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.

Copy link
Contributor

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.

@JoeSSS
Copy link
Contributor Author

JoeSSS commented Oct 22, 2017

PR is ready to be reviewed ;) @BasThomas @q231950

@BasThomas
Copy link
Contributor

BasThomas commented Oct 23, 2017

Uh-oh: it seems to be crashing locally:

2017-10-23 09:10:06.982187+0200 Calabash Launcher[1282:254051] *** Assertion failure in -[NSMenu itemAtIndex:], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.83.101/Menus.subproj/NSMenu.m:940
2017-10-23 09:10:06.982400+0200 Calabash Launcher[1282:254051] Failed to set (contentViewController) user defined inspected property on (NSWindow): Invalid parameter not satisfying: index >= 0
rm: /tmp/calabash_pipe: No such file or directory

screen shot 2017-10-23 at 09 10 56

Copy link
Contributor

@BasThomas BasThomas left a 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 {
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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!
Copy link
Contributor

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] = [""]
Copy link
Contributor

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: [""])
Copy link
Contributor

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 {
Copy link
Contributor

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]
Copy link
Contributor

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)
Copy link
Contributor

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: [""])
Copy link
Contributor

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()
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #32 and #33

@JoeSSS JoeSSS merged commit 80150ff into master Oct 23, 2017
@JoeSSS JoeSSS deleted the simplification branch October 23, 2017 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants