Clean up tests
This commit is contained in:
parent
903ed61722
commit
855396972a
@ -32,7 +32,7 @@ taskrun.triggered = function triggered() {
|
||||
|
||||
// Do this when a task is interrupted
|
||||
taskrun.interrupt = function interrupt() {
|
||||
grunt.log.writeln('').write('Previously ran tasks have been interrupted...'.yellow);
|
||||
grunt.log.writeln('').write('Scheduled tasks have been interrupted...'.yellow);
|
||||
taskrun.startedAt = false;
|
||||
};
|
||||
|
||||
|
4
test/fixtures/nospawn/Gruntfile.js
vendored
4
test/fixtures/nospawn/Gruntfile.js
vendored
@ -41,9 +41,11 @@ module.exports = function(grunt) {
|
||||
}).listen(port);
|
||||
grunt.log.writeln('Server is listening...');
|
||||
} else {
|
||||
var done = this.async();
|
||||
http.request({port: port}, function(res) {
|
||||
res.on('data', function(buf) {
|
||||
grunt.log.writeln(buf);
|
||||
done();
|
||||
});
|
||||
}).end();
|
||||
}
|
||||
@ -51,7 +53,7 @@ module.exports = function(grunt) {
|
||||
|
||||
// A long running task
|
||||
grunt.registerTask('long', function() {
|
||||
setTimeout(this.async(), 3000);
|
||||
setTimeout(this.async(), 2000);
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['server', 'watch']);
|
||||
|
@ -34,7 +34,7 @@ helper.assertTask = function assertTask(task, options) {
|
||||
spawnOptions.push(val);
|
||||
});
|
||||
// Add the tasks to run
|
||||
spawnOptions.push(task);
|
||||
spawnOptions = spawnOptions.concat(task);
|
||||
|
||||
// Return an interface for testing this task
|
||||
function returnFunc(runs, done) {
|
||||
|
@ -26,17 +26,14 @@ exports.nospawn = {
|
||||
nospawn: function(test) {
|
||||
test.expect(3);
|
||||
var cwd = path.resolve(fixtures, 'nospawn');
|
||||
var assertWatch = helper.assertTask('watch', {cwd:cwd});
|
||||
assertWatch([function() {
|
||||
var assertWatch = helper.assertTask(['server', 'watch'], {cwd:cwd});
|
||||
assertWatch(function() {
|
||||
var write = 'var nospawn = true;';
|
||||
grunt.file.write(path.join(cwd, 'lib', 'nospawn.js'), write);
|
||||
}, function() {
|
||||
var write = 'var nospawn = true;';
|
||||
grunt.file.write(path.join(cwd, 'lib', 'nospawn.js'), write);
|
||||
}], function(result) {
|
||||
}, function(result) {
|
||||
helper.verboseLog(result);
|
||||
var count = result.match((new RegExp('File "lib' + path.sep + 'nospawn.js" changed', 'g'))).length;
|
||||
test.equal(count, 2, 'Watch should have fired twice when nospawn.js has changed.');
|
||||
var count = result.match((new RegExp('Running "watch" task', 'g'))).length;
|
||||
test.equal(count, 2, 'Watch should have fired twice.');
|
||||
test.ok(result.indexOf('Server is listening...') !== -1, 'server should have been started.');
|
||||
test.ok(result.indexOf('Server is talking!') !== -1, 'server should have responded.');
|
||||
test.done();
|
||||
@ -58,7 +55,7 @@ exports.nospawn = {
|
||||
helper.verboseLog(result);
|
||||
var count = result.match((new RegExp('Running "long" task', 'g'))).length;
|
||||
test.equal(count, 4, 'long task should have been ran only 4 times.');
|
||||
test.ok(result.indexOf('Previously ran tasks have been interrupted') !== -1, 'tasks should have been interrupted.');
|
||||
test.ok(result.indexOf('have been interrupted') !== -1, 'tasks should have been interrupted.');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
@ -94,7 +94,7 @@ exports.watchConfig = {
|
||||
}, 1000);
|
||||
}, function(result) {
|
||||
helper.verboseLog(result);
|
||||
test.ok(result.indexOf('has been interrupted') !== -1, 'Task should have been interrupted.');
|
||||
test.ok(result.indexOf('have been interrupted') !== -1, 'Task should have been interrupted.');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user