2016-07-23 01:38:36 +02:00
|
|
|
'use strict';
|
2016-12-21 01:27:56 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const exec = require('child_process').exec;
|
|
|
|
const path = require('path');
|
2016-07-23 01:38:36 +02:00
|
|
|
|
|
|
|
// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read
|
|
|
|
// the directory there.
|
|
|
|
if (process.platform === 'freebsd') {
|
|
|
|
common.skip('platform not supported.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function test(env, cb) {
|
2016-12-21 01:27:56 +01:00
|
|
|
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) => {
|
2016-07-23 01:38:36 +02:00
|
|
|
assert(err);
|
2016-12-21 01:27:56 +01:00
|
|
|
assert.strictEqual(stdout, '');
|
|
|
|
assert.notStrictEqual(stderr, '');
|
2016-07-23 01:38:36 +02:00
|
|
|
cb('' + stderr);
|
2016-12-21 01:27:56 +01:00
|
|
|
}));
|
2016-07-23 01:38:36 +02:00
|
|
|
}
|
|
|
|
|
2016-12-21 01:27:56 +01:00
|
|
|
test({ NODE_DEBUG: '' }, common.mustCall((data) => {
|
2016-07-23 01:38:36 +02:00
|
|
|
assert(/EISDIR/.test(data));
|
|
|
|
assert(!/test-fs-readfile-error/.test(data));
|
|
|
|
}));
|
|
|
|
|
2016-12-21 01:27:56 +01:00
|
|
|
test({ NODE_DEBUG: 'fs' }, common.mustCall((data) => {
|
2016-07-23 01:38:36 +02:00
|
|
|
assert(/EISDIR/.test(data));
|
|
|
|
assert(/test-fs-readfile-error/.test(data));
|
|
|
|
}));
|