Skip to content

Commit

Permalink
Add test case for exclude. Relates to gruntjs#65.
Browse files Browse the repository at this point in the history
  • Loading branch information
adjohnson916 committed Jul 5, 2015
1 parent beebec8 commit 381f370
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module.exports = function(grunt) {
shortPathTest: ['tmp/sample_short'],
longPathTest: {
src: ['tmp/sample_long']
}
},
exclude: ['tmp/end_01/**/*', '!tmp/end_01/1.txt']
},

// Unit tests.
Expand All @@ -49,6 +50,13 @@ module.exports = function(grunt) {
grunt.registerTask('copy', 'Copy fixtures to a temp location.', function() {
grunt.file.copy('test/fixtures/sample_long/long.txt', 'tmp/sample_long/long.txt');
grunt.file.copy('test/fixtures/sample_short/short.txt', 'tmp/sample_short/short.txt');
var cwd = 'test/fixtures/start';
grunt.file.expand({
cwd: cwd
}, '**/*')
.forEach(function (file) {
grunt.file.copy(cwd + '/' + file, 'tmp/end_01/' + file);
});
});

// Whenever the 'test' task is run, first create some files to be cleaned,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"rimraf": "^2.2.1"
},
"devDependencies": {
"dir-compare": "0.0.2",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-internal": "^0.4.10",
Expand Down
6 changes: 6 additions & 0 deletions test/clean_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var grunt = require('grunt');
var dircompare = require('dir-compare');

exports.clean = {
shortPathTest: function(test) {
Expand All @@ -17,6 +18,11 @@ exports.clean = {
var expected = grunt.file.exists('tmp/sample_long');
test.equal(expected, false, 'should remove the long directory using clean');

test.done();
},
exclude: function (test) {
var res = dircompare.compareSync('test/expected/end_01', 'tmp/end_01');
test.equal(true, res.equal, 'should match exclusions');
test.done();
}
};
Empty file added test/expected/end_01/1.txt
Empty file.
Empty file added test/fixtures/start/1.txt
Empty file.
Empty file added test/fixtures/start/2.txt
Empty file.

0 comments on commit 381f370

Please sign in to comment.