From 064e986d26e00b54745d51970df5c70b01deb5de Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Mon, 21 Jul 2014 13:17:16 -0400 Subject: [PATCH] sh.ls() fails when stack sized is reached for deep recursive listings: RangeError: Maximum call stack size exceeded --- tests/bugs/ls-depth-bug.js | 28 ++++++++++++++++++++++++++++ tests/index.js | 1 + 2 files changed, 29 insertions(+) create mode 100644 tests/bugs/ls-depth-bug.js diff --git a/tests/bugs/ls-depth-bug.js b/tests/bugs/ls-depth-bug.js new file mode 100644 index 0000000..a5a5f5c --- /dev/null +++ b/tests/bugs/ls-depth-bug.js @@ -0,0 +1,28 @@ +var Filer = require('../..'); +var util = require('../lib/test-utils.js'); +var expect = require('chai').expect; + +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(); + var sh = fs.Shell(); + + // The specific depth at which this will fail is based on the depth + // of the call stack, since sh.ls() is recursive, so it can be less + // than this in some cases, but this should trigger it in *this* case. + var path = '/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20'; + + 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(); + }); + }); + }); +}); diff --git a/tests/index.js b/tests/index.js index b427ee3..e426521 100644 --- a/tests/index.js +++ b/tests/index.js @@ -68,3 +68,4 @@ require("./spec/node-js/simple/test-fs-watch-recursive"); require("./bugs/issue105"); require("./bugs/issue106"); require("./bugs/issue239"); +require("./bugs/ls-depth-bug"); \ No newline at end of file