0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-cwd-enoent-preload.js
Santiago Gimeno dee0e3a333 test: use common platform helpers everywhere
Use the common.isWindows, common.isFreeBSD and common.isSunOS where
possible.
Add common.isOSX and common.isLinux.
Fix `test-fs-read-file-sync-hostname` as in its current form was not
being run anywhere.

PR-URL: https://github.com/nodejs/node/pull/7845
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-07-27 08:25:26 +02:00

29 lines
873 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix) {
common.skip('cannot rmdir current working directory');
return;
}
const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
const abspathFile = require('path').join(common.fixturesDir, 'a.js');
common.refreshTmpDir();
fs.mkdirSync(dirname);
process.chdir(dirname);
fs.rmdirSync(dirname);
const proc = spawn(process.execPath, ['-r', abspathFile, '-e', '0']);
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
proc.once('exit', common.mustCall(function(exitCode, signalCode) {
assert.strictEqual(exitCode, 0);
assert.strictEqual(signalCode, null);
}));