0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-fs-readfile-error.js
Sakthipriyan Vairamani 79c865a53f test: changing process.exit to return while skipping tests
This patch uses `return` statement to skip the test instead of using
`process.exit` call.

PR-URL: https://github.com/nodejs/io.js/pull/2109
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2015-07-20 15:50:42 +05:30

43 lines
1.1 KiB
JavaScript

'use strict';
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.log('1..0 # Skipped: platform not supported.');
return;
}
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);
});