Skip to content

Commit

Permalink
test: should not crash with 20-thousand files
Browse files Browse the repository at this point in the history
  • Loading branch information
arve0 committed May 31, 2016
1 parent 493c7e5 commit 3a4d07c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
test/build-*
test/build-*
test/out
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"devDependencies": {
"assert-dir-equal": "^1.0.1",
"metalsmith": "^1.0.1",
"metalsmith": "^2.1.0",
"mocha": "^2.1.0"
}
}
26 changes: 26 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var assert = require('assert');
var equal = require('assert-dir-equal');
var Metalsmith = require('metalsmith');
var pandoc = require('..');
var fs = require('fs');

describe('metalsmith-pandoc', function(){
it('should convert markdown files to html', function(done){
Expand All @@ -28,4 +29,29 @@ describe('metalsmith-pandoc', function(){
done();
});
});

it('should be able to process 20 thousand files', function(done){
var many = 20000;
this.timeout(0);

Metalsmith('test')
.destination('out')
.concurrency(1000) // avoid file table overflow (ENFILE)
.use(function (files) {
// add fake files
for (var i = 0; i < many; i += 1) {
var filename = i + '.md';
files[filename] = {
title: 'fake ' + i,
contents: 'sample markdown'
};
}
})
.use(pandoc())
.build(function(err){
if (err) return done(err);
assert.equal(fs.readdirSync('test/out').length, many + 1);
done();
});
});
});

0 comments on commit 3a4d07c

Please sign in to comment.