0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/parallel/test-fs-readfile-error.js
Fedor Indutny 50648d6018 test: disable fs-readfile-error on FreeBSD
FreeBSD does not return EISDIR when reading "/".

PR-URL: https://github.com/iojs/io.js/pull/332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-13 20:36:44 +03:00

42 lines
1.1 KiB
JavaScript

var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
var path = require('path');
// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read
// the directory there.
if (process.platform === 'freebsd') {
console.error('Skipping test, platform not supported.');
process.exit();
}
var callbacks = 0;
function test(env, cb) {
var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
var execPath = process.execPath + ' ' + filename;
var options = { env: env || {} };
exec(execPath, options, function(err, stdout, stderr) {
assert(err);
assert.equal(stdout, '');
assert.notEqual(stderr, '');
cb('' + stderr);
});
}
test({ NODE_DEBUG: '' }, function(data) {
assert(/EISDIR/.test(data));
assert(!/test-fs-readfile-error/.test(data));
callbacks++;
});
test({ NODE_DEBUG: 'fs' }, function(data) {
assert(/EISDIR/.test(data));
assert(/test-fs-readfile-error/.test(data));
callbacks++;
});
process.on('exit', function() {
assert.equal(callbacks, 2);
});