Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coffee script cakefile task not finishing

I have the following cakefile task to run selenium tests which runs successfully and gets to the end of the tests but doesn't exit.

muffin = require 'muffin'
wrench = require 'wrench'
http   = require 'http'
fs     = require 'fs'
spawn  = require('child_process').spawn
exec   = require('child_process').exec

task 'selenium', 'run selenium tests', (options) ->
    sel = require './test/selenium'
    app = spawn 'node', ['app.js']
    app.stdout.on 'data', (data) ->
        if /listening on port/.test data
            selenium = spawn 'selenium'
            selenium.stdout.on 'data', (data) ->
                console.log 'stdout: ' + data
                if /Started.*jetty.Server/.test data
                    sel.run ->
                        app.stdin.end()
                        selenium.stdin.end()
                        console.log 'completed Selenium Tests'

Is there a way I can tell the task to finish? I get the 'completed Selenium Tests' logged in the console.

like image 836
Dave Taylor Avatar asked Jun 29 '26 17:06

Dave Taylor


1 Answers

If one of the two child processes (app and selenium) is still running, the main process will keep running. Calling stdin.end() on them doesn't change this. What you want to do is to force them to die, with the aptly-named kill method:

app.kill()
selenium.kill()
console.log 'completed Selenium Tests'
like image 87
Trevor Burnham Avatar answered Jul 02 '26 06:07

Trevor Burnham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!