Process only existing files and directories in the test harness

`fs.statSync` throws `ENOENT` if there is a symlink to a nonexistent
target.  This can be avoided by checking that the entry exists before
using it.

(This is annoying when editing tests in Emacs, since it keeps lock files
for modified-but-unsaved files, which are `.#foo` symlinks to a
nonexistent target.)
This commit is contained in:
Eli Barzilay 2021-04-09 05:08:39 -04:00
parent b0c2860a68
commit 716441d343

View File

@ -72,6 +72,7 @@ namespace Harness {
for (const file of fs.readdirSync(folder)) {
const pathToFile = pathModule.join(folder, file);
if (!fs.existsSync(pathToFile)) continue; // ignore invalid symlinks
const stat = fs.statSync(pathToFile);
if (options.recursive && stat.isDirectory()) {
paths = paths.concat(filesInFolder(pathToFile));