From ab3d1c05057d3608612a6665223efeaed8632981 Mon Sep 17 00:00:00 2001 From: Ville Saukkonen Date: Tue, 15 Nov 2016 13:23:54 +0200 Subject: [PATCH] remove check for file existence to allow require to choke on broken symlinks later on --- lib/utils.js | 3 +-- test/acceptance/file-utils.spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 0a47eb4fc1..bf430b9168 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -17,7 +17,6 @@ var readdirSync = require('fs').readdirSync; var statSync = require('fs').statSync; var watchFile = require('fs').watchFile; var lstatSync = require('fs').lstatSync; -var existsSync = require('fs').existsSync; var toISOString = require('./to-iso-string'); /** @@ -256,7 +255,7 @@ exports.files = function (dir, ext, ret) { path = join(dir, path); if (lstatSync(path).isDirectory()) { exports.files(path, ext, ret); - } else if (path.match(re) && existsSync(path)) { + } else if (path.match(re)) { ret.push(path); } }); diff --git a/test/acceptance/file-utils.spec.js b/test/acceptance/file-utils.spec.js index 08569c923a..12dbddf878 100644 --- a/test/acceptance/file-utils.spec.js +++ b/test/acceptance/file-utils.spec.js @@ -8,7 +8,7 @@ var mkdirp = require('mkdirp'); var rimraf = require('rimraf'); describe('file utils', function () { - var tmpDir = path.join(os.tmpDir(), 'mocha-file-test-folder'); + var tmpDir = path.join(os.tmpDir(), 'mocha-file-lookup'); var existsSync = fs.existsSync; var tmpFile = path.join.bind(path, tmpDir); var symlinkSupported = false; @@ -37,7 +37,7 @@ describe('file utils', function () { }); describe('.lookupFiles', function () { - (symlinkSupported ? it : it.skip)('lookupFiles should not choke on broken symlinks', function () { + (symlinkSupported ? it : it.skip)('should not return broken symlink file path', function () { expect(utils.lookupFiles(tmpDir, ['js'], false)) .to .contain(tmpFile('mocha-utils-link.js')) @@ -81,7 +81,7 @@ describe('file utils', function () { }); describe('.files', function () { - (symlinkSupported ? it : it.skip)('should not choke on broken symlinks', function () { + (symlinkSupported ? it : it.skip)('should return broken symlink file path', function () { expect(utils.files(tmpDir, ['js'])) .to.contain(tmpFile('mocha-utils-link.js')) .and.contain(tmpFile('mocha-utils.js')) @@ -96,7 +96,7 @@ describe('file utils', function () { .to.be(false); expect(utils.files(tmpDir, ['js'])) - .to.eql([]); + .to.eql([tmpFile('mocha-utils-link.js')]); }); });