Skip to content

Commit

Permalink
[test] Update tests to be consistent with new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed May 29, 2011
1 parent 921966a commit d6b0d0e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/error-on-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ var sys = require('sys');
setTimeout(function () {
sys.puts('Throwing error now.');
throw new Error('User generated fault.');
}, 1000);
}, 200);
4 changes: 2 additions & 2 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ forever.list = function (format, procs) {
// Utility function for removing excess pid and
// config, and log files used by forever.
//
forever.cleanUp = function (cleanLogs) {
forever.cleanUp = function (cleanLogs, allowManager) {
var emitter = new events.EventEmitter(),
processes = getAllProcesses(true),
pidPath = forever.config.get('pidPath');
Expand All @@ -373,7 +373,7 @@ forever.cleanUp = function (cleanLogs) {
function cleanProcess (proc, next) {
checkProcess(proc.pid, function (child) {
checkProcess(proc.foreverPid, function (manager) {
if (!child && !manager || proc.dead) {
if (!child && !manager || (!child && manager && allowManager) || proc.dead) {
fs.unlink(path.join(pidPath, proc.uid + '.fvr'), function () {
fs.unlink(path.join(pidPath, proc.uid + '.pid'), function () {
//
Expand Down
18 changes: 18 additions & 0 deletions test/forever-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ vows.describe('forever').addBatch({
topic: function () {
var child = new (forever.Forever)(path.join(__dirname, '..', 'examples', 'error-on-timer.js'), {
max: 3,
minUptime: 200,
silent: true,
outFile: 'test/stdout.log',
errFile: 'test/stderr.log',
Expand Down Expand Up @@ -75,4 +76,21 @@ vows.describe('forever').addBatch({
assert.isTrue(err.message.indexOf('does not exist') !== -1);
}
}
}).addBatch({
"When the tests are over": {
"a call to forever.list()": {
topic: function () {
var that = this;
var tidy = forever.cleanUp(true, true);

tidy.on('cleanUp', function () {
that.callback(null, forever.list(false));
});
},
"should respond with no processes": function (err, procs) {
assert.isNull(err);
assert.isNull(procs);
}
}
}
}).export(module);
2 changes: 1 addition & 1 deletion test/multiple-processes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var sys = require('sys'),
vows = require('vows'),
forever = require('forever');

vows.describe('forever').addBatch({
vows.describe('forever/multiple-processes').addBatch({
"When using forever": {
"and spawning two processes using the same script": {
topic: function () {
Expand Down
2 changes: 1 addition & 1 deletion test/spin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var sys = require('sys'),
vows = require('vows'),
forever = require('forever');

vows.describe('forever').addBatch({
vows.describe('forever/spin-restart').addBatch({
"When using forever": {
"and spawning a script that spin restarts": {
topic: function () {
Expand Down

0 comments on commit d6b0d0e

Please sign in to comment.