forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-fs-readfile-error.js
More file actions
32 lines (28 loc) · 1 KB
/
test-fs-readfile-error.js
File metadata and controls
32 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const common = require('../common');
// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read
// the directory there.
if (common.isFreeBSD)
common.skip('platform not supported.');
const assert = require('assert');
const exec = require('child_process').exec;
const path = require('path');
function test(env, cb) {
const filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
const execPath = `"${process.execPath}" "${filename}"`;
const options = { env: Object.assign({}, process.env, env) };
exec(execPath, options, common.mustCall((err, stdout, stderr) => {
assert(err);
assert.strictEqual(stdout, '');
assert.notStrictEqual(stderr, '');
cb(String(stderr));
}));
}
test({ NODE_DEBUG: '' }, common.mustCall((data) => {
assert(/EISDIR/.test(data));
assert(!/test-fs-readfile-error/.test(data));
}));
test({ NODE_DEBUG: 'fs' }, common.mustCall((data) => {
assert(/EISDIR/.test(data));
assert(/test-fs-readfile-error/.test(data));
}));