Skip to content

Commit

Permalink
Update test-process-cwd-deleted.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankush1oo8 authored Feb 25, 2025
1 parent e23e544 commit c29b27a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/parallel/test-process-cwd-deleted.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
// while it is starting up.

const common = require('../common');

const { fork } = require('node:child_process');
const { rmSync } = require('node:fs');
const { strictEqual, ok } = require('node:assert');
const assert = require('node:assert'); // Import assert properly
const { Buffer } = require('node:buffer');

if (process.argv[2] === 'child') {
return;
try {
while (true) {
process.cwd(); // Continuously call process.cwd()
}
} catch (err) {
console.error(err);
process.exit(1); // Ensure the process exits with failure
}
}

const tmpdir = require('../common/tmpdir');
Expand All @@ -25,10 +31,11 @@ const proc = fork(__filename, ['child'], {
cwd: tmpDir,
silent: true,
});

proc.on('spawn', common.mustCall(() => rmSync(tmpDir, { recursive: true })));

proc.on('exit', common.mustCall((code) => {
strictEqual(code, 1);
assert.strictEqual(code, 1);
proc.stderr.toArray().then(common.mustCall((chunks) => {
const buf = Buffer.concat(chunks);
assert.match(buf.toString(), /Current working directory does not exist/);
Expand Down

0 comments on commit c29b27a

Please # to comment.