Skip to content

Commit

Permalink
add time logging to test, make test faster, increase timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Aug 27, 2020
1 parent c783058 commit cd244d4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/ManyWatchers.js
Expand Up @@ -11,11 +11,14 @@ const fixtures = path.join(__dirname, "fixtures");
const testHelper = new TestHelper(fixtures);

describe("ManyWatchers", function() {
this.timeout(240000);
this.timeout(600000);
beforeEach(testHelper.before);
afterEach(testHelper.after);

it("should watch more than 4096 directories", done => {
console.time("creating files");
// windows is very slow in creating so many files
// this can take about 1 minute
const files = [];
for (let i = 1; i < 5000; i++) {
let highBit = 1;
Expand All @@ -40,24 +43,31 @@ describe("ManyWatchers", function() {
}
testHelper.file("file");
files.push(path.join(fixtures, "file"));
console.timeEnd("creating files");
testHelper.tick(10000, () => {
const w = new Watchpack({
aggregateTimeout: 1000
});
w.on("aggregated", function(changes) {
console.timeEnd("detecting change event");
Array.from(changes).should.be.eql([
path.join(fixtures, "4096/900/file")
]);
w.close();
done();
});
for (let i = 100; i < files.length; i += 987) {
console.time("creating/closing watchers");
// MacOS is very slow in creating and destroying watchers
// This can take about 5 minutes
for (let i = 100; i < files.length; i += 2432) {
for (let j = 0; j < files.length - i; j += 987) {
w.watch({ files: files.slice(j, j + i) });
}
}
w.watch({ files });
console.timeEnd("creating/closing watchers");
testHelper.tick(10000, () => {
console.time("detecting change event");
testHelper.file("4096/900/file");
});
});
Expand Down

0 comments on commit cd244d4

Please sign in to comment.