-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Change & tests for failing child processes (fixes #24)
- Loading branch information
Showing
3 changed files
with
60 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
var lab = exports.lab = require('lab').script(); | ||
var describe = lab.describe; | ||
var it = lab.it; | ||
var expect = require('code').expect; | ||
|
||
var cp = require('child_process'); | ||
var asyncDone = require('../'); | ||
|
||
|
||
function execSuccess(){ | ||
return cp.exec('echo hello world'); | ||
} | ||
|
||
function execFail(){ | ||
return cp.exec('foo-bar-baz hello world'); | ||
} | ||
|
||
function spawnSuccess(){ | ||
return cp.spawn('echo', ['hello world']); | ||
} | ||
|
||
function spawnFail(){ | ||
return cp.spawn('foo-bar-baz', ['hello world']); | ||
} | ||
|
||
describe('child processes', function(){ | ||
it('should handle successful exec', function(done){ | ||
asyncDone(execSuccess, function(err){ | ||
expect(err).to.not.be.instanceof(Error); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should handle failing exec', function(done){ | ||
asyncDone(execFail, function(err){ | ||
expect(err).to.be.an.instanceof(Error); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should handle successful spawn', function(done){ | ||
asyncDone(spawnSuccess, function(err){ | ||
expect(err).to.not.be.instanceof(Error); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should handle failing spawn', function(done){ | ||
asyncDone(spawnFail, function(err){ | ||
expect(err).to.be.an.instanceof(Error); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters