2014-07-21 17:17:16 +00:00
|
|
|
var Filer = require('../..');
|
|
|
|
var util = require('../lib/test-utils.js');
|
|
|
|
var expect = require('chai').expect;
|
2014-07-21 19:08:39 +00:00
|
|
|
var async = require('../../lib/async.js');
|
2014-07-21 17:17:16 +00:00
|
|
|
|
|
|
|
describe('sh.ls and deep directory trees', function() {
|
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
|
|
|
|
|
|
|
it('should not crash when calling sh.ls() on deep directory layouts', function(done) {
|
|
|
|
var fs = util.fs();
|
2014-10-24 18:19:17 +00:00
|
|
|
var sh = new fs.Shell();
|
2014-07-21 17:17:16 +00:00
|
|
|
|
2014-07-21 19:08:39 +00:00
|
|
|
var path = '';
|
|
|
|
for(var i=0; i<50; i++) {
|
|
|
|
path += '/' + i;
|
|
|
|
}
|
2014-07-21 17:17:16 +00:00
|
|
|
|
|
|
|
sh.mkdirp(path, function(err) {
|
|
|
|
if(err) throw err;
|
|
|
|
|
|
|
|
sh.ls('/', {recursive: true}, function(err, listing) {
|
|
|
|
expect(err).not.to.exist;
|
|
|
|
expect(listing).to.exist;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2014-07-21 19:08:39 +00:00
|
|
|
|
|
|
|
it('should not crash when calling sh.ls() on wide directory layouts', function(done) {
|
|
|
|
var fs = util.fs();
|
2014-10-24 18:19:17 +00:00
|
|
|
var sh = new fs.Shell();
|
2014-07-21 19:08:39 +00:00
|
|
|
|
|
|
|
var dirName = '/dir';
|
|
|
|
|
|
|
|
fs.mkdir(dirName, function(err) {
|
|
|
|
if(err) throw err;
|
|
|
|
|
|
|
|
var paths = [];
|
|
|
|
for(var i=0; i<100; i++) {
|
|
|
|
paths.push(Filer.Path.join(dirName, ''+i));
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeFile(path, callback) {
|
|
|
|
fs.writeFile(path, 'data', callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
async.eachSeries(paths, writeFile, function(err) {
|
|
|
|
if(err) { console.log('error', err); throw err; }
|
|
|
|
|
|
|
|
sh.ls('/', {recursive: true}, function(err, listing) {
|
|
|
|
expect(err).not.to.exist;
|
|
|
|
expect(listing).to.exist;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2014-07-21 17:17:16 +00:00
|
|
|
});
|