-
Notifications
You must be signed in to change notification settings - Fork 945
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Please note that tests are synchronous because of possible race conditions.
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* watch-test.js | ||
* | ||
* (C) 2010 and Charlie Robbins | ||
* MIT LICENSE | ||
* | ||
*/ | ||
|
||
var assert = require('assert'), | ||
path = require('path'), | ||
fs = require('fs'), | ||
vows = require('vows'), | ||
forever = require('../lib/forever'); | ||
|
||
vows.describe('forever/watch').addBatch({ | ||
'When using forever with watch enabled': { | ||
'forever should': { | ||
topic: forever.start('daemon.js', { | ||
silent: true, | ||
options: ['-p', '8090'], | ||
watch: true, | ||
sourceDir: path.join(__dirname, 'fixtures', 'watch') | ||
}), | ||
'have correct options set': function (child) { | ||
assert.isTrue(child.watchIgnoreDotFiles); | ||
assert.equal(fs.realpathSync(path.join(__dirname, 'fixtures', 'watch')), | ||
fs.realpathSync(child.watchDirectory)); | ||
}, | ||
'when file changes': { | ||
topic: function (child) { | ||
child.once('restart', this.callback); | ||
fs.writeFileSync(path.join(__dirname, 'fixtures', 'watch', 'file'), | ||
'// hello, I know nodejitsu.'); | ||
}, | ||
'restart the script': function (child, _) { | ||
fs.writeFileSync(path.join(__dirname, 'fixtures', 'watch', 'file'), | ||
'/* hello, I know nodejitsu. */'); | ||
} | ||
}, | ||
'when file is added': { | ||
topic: function (child) { | ||
child.once('restart', this.callback); | ||
fs.writeFileSync(path.join(__dirname, 'fixtures', 'watch', 'newFile'), ''); | ||
}, | ||
'restart the script': function (child, _) { | ||
fs.unlinkSync(path.join(__dirname, 'fixtures', 'watch', 'newFile')); | ||
} | ||
}, | ||
'when file is removed': { | ||
topic: function (child) { | ||
child.once('restart', this.callback); | ||
fs.unlinkSync(path.join(__dirname, 'fixtures', 'watch', 'removeMe')); | ||
}, | ||
'restart the script': function (child, _) { | ||
fs.writeFileSync(path.join(__dirname, 'fixtures', 'watch', 'removeMe'), ''); | ||
} | ||
}, | ||
'read .foreverignore file': { | ||
'and store ignore patterns': function (child) { | ||
assert.deepEqual( | ||
child.watchIgnorePatterns, | ||
fs.readFileSync( | ||
path.join(__dirname, 'fixtures', 'watch', '.foreverignore'), | ||
'utf8' | ||
).split("\n") | ||
); | ||
} | ||
} | ||
} | ||
} | ||
}).export(module); | ||
|