From 381f37020e271e5e1216da01e7272f5771f13a0c Mon Sep 17 00:00:00 2001 From: "Anders D. Johnson" Date: Sat, 4 Jul 2015 19:20:14 -0500 Subject: [PATCH] Add test case for exclude. Relates to #65. --- Gruntfile.js | 10 +++++++++- package.json | 1 + test/clean_test.js | 6 ++++++ test/expected/end_01/1.txt | 0 test/fixtures/start/1.txt | 0 test/fixtures/start/2.txt | 0 6 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/expected/end_01/1.txt create mode 100644 test/fixtures/start/1.txt create mode 100644 test/fixtures/start/2.txt diff --git a/Gruntfile.js b/Gruntfile.js index 1e5541c..098a2af 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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. @@ -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, diff --git a/package.json b/package.json index 2b21756..693408e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/clean_test.js b/test/clean_test.js index 0d3e2f4..1f3fc60 100644 --- a/test/clean_test.js +++ b/test/clean_test.js @@ -1,6 +1,7 @@ 'use strict'; var grunt = require('grunt'); +var dircompare = require('dir-compare'); exports.clean = { shortPathTest: function(test) { @@ -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(); } }; diff --git a/test/expected/end_01/1.txt b/test/expected/end_01/1.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/start/1.txt b/test/fixtures/start/1.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/start/2.txt b/test/fixtures/start/2.txt new file mode 100644 index 0000000..e69de29