Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Test case for exclusions in Gaze. #19

Closed
wants to merge 2 commits into from

1 participant

@itsjamie

@shama, Testcase!

This is related to gruntjs/grunt-contrib-watch#20, will allow us to change the task to pass the unexpanded Globs to Gaze.

Assuming this is accepted, I'm pretty close to getting it fixed. I've got the exclusion test itself working, but it ends up being too greedy, and fires add events from Gaze on the .txt file.. etc. Not sure what's going on there yet.

@itsjamie itsjamie closed this
@itsjamie itsjamie deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 0 deletions.
  1. +36 −0 test/exclusion_test.js
View
36 test/exclusion_test.js
@@ -0,0 +1,36 @@
+var Gaze = require('../lib/gaze.js').Gaze;
+var path = require('path');
+var fs = require('fs');
+
+exports.exclusion = {
+ setUp: function(done) {
+ process.chdir(path.resolve(__dirname, 'fixtures'));
+ done();
+ },
+ exclusionTest: function(test) {
+ var expected = {
+ 'Project (LO)/': ['one.js'],
+ '.': ['one.js'],
+ 'sub/': ['one.js', 'two.js']
+ };
+ test.expect(2);
+ var gaze = new Gaze(['**/*.js', '!nested/**/*.js'], function(err, watcher) {
+ test.deepEqual(this.relative(null, true), expected);
+ this.on('all', function(status, filepath) {
+ test.equal('one.js', path.basename(filepath));
+ watcher.close();
+ test.done();
+ });
+ //Write a file that shouldn't ever match a pattern, but is in the same directory as one that does.
+ fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'two.txt'), 'Will I be watched?');
+
+ //Write a file that is part of the exclusion.
+ fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'nested', 'sub', 'two.js'), 'var two = true;');
+
+ //Give time for watcher to respond and see if it responds to either file that shouldn't be watched.
+ setTimeout(function() {
+ //fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'one.js'), 'var one = true;');
+ }, 2000);
+ })
+ }
+}
Something went wrong with that request. Please try again.