Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases for excludes. #75

Merged
merged 2 commits into from
Nov 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ module.exports = function(grunt) {
shortPathTest: ['tmp/sample_short'],
longPathTest: {
src: ['tmp/sample_long']
}
},
exclude: ['tmp/end_01/**/*', '!tmp/end_01/1.txt'],
excludeSub: ['tmp/end_02/**/*.*', '!tmp/end_02/2/**/*']
},

// Unit tests.
Expand All @@ -49,6 +51,20 @@ 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) {
var ecwd = 'test/expected';
grunt.file.expand({
cwd: ecwd
}, '*')
.forEach(function (dir) {
grunt.file.copy(cwd + '/' + file, 'tmp/' + dir + '/' + 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
11 changes: 11 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,16 @@ 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.same, 'should match exclusions');
test.done();
},
excludeSub: function (test) {
var res = dircompare.compareSync('test/expected/end_02', 'tmp/end_02');
test.equal(true, res.same, 'should match exclusions for sub');
test.done();
}
};
Empty file added test/expected/end_01/1.txt
Empty file.
Empty file added test/expected/end_02/2/1.txt
Empty file.
Empty file added test/fixtures/start/1.txt
Empty file.
Empty file added test/fixtures/start/2.txt
Empty file.
Empty file added test/fixtures/start/2/1.txt
Empty file.