node/test/parallel/test-cwd-enoent-repl.js
Richard Lau 035e06317a test: disambiguate AIX and IBM i
When built with Python 3.9 on IBM i, `process.platform` will return
`os400` instead of `aix`. In preparation for this, make `common.isAIX`
only return true for AIX and update the tests to add checks for
`common.isIBMi` where they were missing.

PR-URL: https://github.com/nodejs/node/pull/48056
Refs: https://github.com/nodejs/node/pull/46739
Refs: https://github.com/nodejs/build/pull/3358
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-09-29 18:26:27 +00:00

31 lines
997 B
JavaScript

'use strict';
const common = require('../common');
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi)
common.skip('cannot rmdir current working directory');
if (!common.isMainThread)
common.skip('process.chdir is not available in Workers');
const assert = require('assert');
const fs = require('fs');
const spawn = require('child_process').spawn;
const tmpdir = require('../common/tmpdir');
const dirname = `${tmpdir.path}/cwd-does-not-exist-${process.pid}`;
tmpdir.refresh();
fs.mkdirSync(dirname);
process.chdir(dirname);
fs.rmdirSync(dirname);
const proc = spawn(process.execPath, ['--interactive']);
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
proc.stdin.write('require("path");\n');
proc.stdin.write('process.exit(42);\n');
proc.once('exit', common.mustCall(function(exitCode, signalCode) {
assert.strictEqual(exitCode, 42);
assert.strictEqual(signalCode, null);
}));