diff --git a/spec/fixtures/task-spec-handler.coffee b/spec/fixtures/task-spec-handler.coffee new file mode 100644 index 000000000..ca30b7ed9 --- /dev/null +++ b/spec/fixtures/task-spec-handler.coffee @@ -0,0 +1,3 @@ +module.exports = -> + console.log "The pid is #{process.pid}" + 'hello' diff --git a/spec/stdlib/task-spec.coffee b/spec/stdlib/task-spec.coffee index 87a95b738..bb7aa031a 100644 --- a/spec/stdlib/task-spec.coffee +++ b/spec/stdlib/task-spec.coffee @@ -20,3 +20,23 @@ describe "Task", -> expect(console.log).not.toHaveBeenCalled() expect(console.error).not.toHaveBeenCalled() expect(console.warn).not.toHaveBeenCalled() + + describe "@once(taskPath, args..., callback)", -> + it "terminates the process after it completes", -> + handlerResult = null + task = Task.once 'fixtures/task-spec-handler', (result) -> + handlerResult = result + + processClosed = false + processErrored = false + childProcess = task.childProcess + spyOn(childProcess, 'kill').andCallThrough() + task.childProcess.on 'error', -> processErrored = true + + waitsFor -> + handlerResult? + + runs -> + expect(handlerResult).toBe 'hello' + expect(childProcess.kill).toHaveBeenCalled() + expect(processErrored).toBe false