0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-27 22:16:50 +01:00
nodejs/test/known_issues/test-cwd-enoent-file.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

35 lines
1.2 KiB
JavaScript

'use strict';
// Refs: https://github.com/nodejs/node/pull/12022
// If the cwd is deleted, Node cannot run files because the module system
// relies on uv_cwd(). The -e and -p flags still work though.
const common = require('../common');
const assert = require('assert');
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) {
// The current working directory cannot be removed on these platforms.
// Change this to common.skip() when this is no longer a known issue test.
assert.fail('cannot rmdir current working directory');
}
const cp = require('child_process');
const fs = require('fs');
if (process.argv[2] === 'child') {
// Do nothing.
} else {
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const dir = fs.mkdtempSync(`${tmpdir.path}/`);
process.chdir(dir);
fs.rmdirSync(dir);
assert.throws(process.cwd,
/^Error: ENOENT: no such file or directory, uv_cwd$/);
const r = cp.spawnSync(process.execPath, [__filename, 'child']);
assert.strictEqual(r.status, 0);
assert.strictEqual(r.signal, null);
assert.strictEqual(r.stdout.toString().trim(), '');
assert.strictEqual(r.stderr.toString().trim(), '');
}