You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB

  1. 'use strict';
  2. var grunt = require('grunt');
  3. var path = require('path');
  4. var fs = require('fs');
  5. var helper = require('./helper');
  6. var fixtures = helper.fixtures;
  7. function cleanUp() {
  8. helper.cleanUp([
  9. 'fail/node_modules',
  10. 'fail/lib/added.js'
  11. ]);
  12. }
  13. exports.fail = {
  14. setUp: function(done) {
  15. cleanUp();
  16. fs.symlinkSync(path.join(__dirname, '../../node_modules'), path.join(fixtures, 'fail', 'node_modules'));
  17. done();
  18. },
  19. tearDown: function(done) {
  20. cleanUp();
  21. done();
  22. },
  23. warn: function(test) {
  24. test.expect(1);
  25. var cwd = path.resolve(fixtures, 'fail');
  26. var assertWatch = helper.assertTask('watch:warn', {cwd: cwd});
  27. assertWatch([function() {
  28. grunt.file.write(path.join(cwd, 'lib/one.js'), 'var one = true;');
  29. }, function() {
  30. grunt.file.write(path.join(cwd, 'lib/one.js'), 'var one = true;');
  31. }], function(result) {
  32. helper.verboseLog(result);
  33. test.ok(result.match(/This task should warn/g).length === 2, 'grunt.warn should not stop the watch task.');
  34. test.done();
  35. });
  36. },
  37. fatal: function(test) {
  38. test.expect(1);
  39. var cwd = path.resolve(fixtures, 'fail');
  40. var assertWatch = helper.assertTask('watch:fatal', {cwd: cwd});
  41. assertWatch([function() {
  42. grunt.file.write(path.join(cwd, 'lib/one.js'), 'var one = true;');
  43. }, function() {
  44. grunt.file.write(path.join(cwd, 'lib/one.js'), 'var one = true;');
  45. }], function(result) {
  46. helper.verboseLog(result);
  47. test.ok(result.match(/This task should be fatal/g).length === 2, 'grunt.fatal should not stop the watch task.');
  48. test.done();
  49. });
  50. },
  51. };