Skip to content

Commit

Permalink
test: fix failure in test/sequential/test-heapdump.js
Browse files Browse the repository at this point in the history
The test was failing when it was being run with superuser privileges,
so this changes the test from attempting to write to a read-only file to
attempting to write to a file with the same name as that of an existing
directory, as that is a more reliable way of making
v8.writeHeapSnapshot() throw even when run with sudo.

Fixes: #41643
Signed-off-by: Darshan Sen <[email protected]>
  • Loading branch information
RaisinTen committed Jan 30, 2022
1 parent ccb8aae commit c6e4596
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/sequential/test-heapdump.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ process.chdir(tmpdir.path);
}

{
const readonlyFile = 'ro';
fs.writeFileSync(readonlyFile, Buffer.alloc(0), { mode: 0o444 });
const directory = 'directory';
fs.mkdirSync(directory);
assert.throws(() => {
writeHeapSnapshot(readonlyFile);
writeHeapSnapshot(directory);
}, (e) => {
assert.ok(e, 'writeHeapSnapshot should error');
assert.strictEqual(e.code, 'EACCES');
assert.strictEqual(e.code, 'EISDIR');
assert.strictEqual(e.syscall, 'open');
return true;
});
Expand Down

0 comments on commit c6e4596

Please sign in to comment.