Skip to content

Commit

Permalink
Add ui text when canceled, Fix bp
Browse files Browse the repository at this point in the history
  • Loading branch information
dsandstrom committed Aug 22, 2014
1 parent 7667920 commit 72534fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
21 changes: 12 additions & 9 deletions lib/buffered-process.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BufferedProcess
# is sent in a final call (optional).
# :exit - The callback {Function} which receives a single argument
# containing the exit status (optional).
constructor: ({command, args, options, stdout, stderr, exit}={}) ->
constructor: ({command, args, options, stdout, stderr, exit}={}, outputCharacters=false) ->
options ?= {}
# Related to joyent/node#2318
if process.platform is "win32"
Expand Down Expand Up @@ -76,13 +76,13 @@ class BufferedProcess

if stdout
stdoutClosed = false
@bufferStream @process.stdout, stdout, ->
@bufferStream @process.stdout, stdout, outputCharacters, ->
stdoutClosed = true
triggerExitCallback()

if stderr
stderrClosed = false
@bufferStream @process.stderr, stderr, ->
@bufferStream @process.stderr, stderr, outputCharacters, ->
stderrClosed = true
triggerExitCallback()

Expand All @@ -98,17 +98,20 @@ class BufferedProcess
# stream - The Stream to read from.
# onLines - The callback to call with each line of data.
# onDone - The callback to call when the stream has closed.
bufferStream: (stream, onLines, onDone) ->
bufferStream: (stream, onLines, outputCharacters, onDone) ->
stream.setEncoding('utf8')
buffered = ''

stream.on 'data', (data) =>
return if @killed
buffered += data
lastNewlineIndex = buffered.lastIndexOf('\n')
if lastNewlineIndex isnt -1
onLines(buffered.substring(0, lastNewlineIndex + 1))
buffered = buffered.substring(lastNewlineIndex + 1)
if !outputCharacters
buffered += data
lastNewlineIndex = buffered.lastIndexOf('\n')
if lastNewlineIndex isnt -1
onLines(buffered.substring(0, lastNewlineIndex + 1))
buffered = buffered.substring(lastNewlineIndex + 1)
else
onLines(data)

stream.on 'close', =>
return if @killed
Expand Down
2 changes: 2 additions & 0 deletions lib/ruby-test-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ class RubyTestView extends View

cancelTest: ->
@runner.cancel()
@spinner?.hide()
@write '\nTests canceled'
8 changes: 2 additions & 6 deletions lib/shell-runner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ module.exports =
@process = @newProcess(fullCommand)

kill: ->
@killed = true
if @process?
@process.kill('SIGKILL')

exit: (code) =>
console.log "Ruby Test exited with #{code}"
@params.exit()

stdout: (output) =>
@params.write output

Expand All @@ -37,5 +32,6 @@ module.exports =
args = ['-c', testCommand]
options = { cwd: @params.cwd }
params = { command, args, options, @stdout, @stderr, @exit }
process = new @processor params
outputCharacters = true
process = new @processor params, outputCharacters
process

0 comments on commit 72534fb

Please sign in to comment.