Skip to content

Commit 82181bb

Browse files
authored
test: fix failure in test/sequential/test-heapdump.js
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 <raisinten@gmail.com> PR-URL: #41772 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent afcfaa0 commit 82181bb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/sequential/test-heapdump.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ process.chdir(tmpdir.path);
2525
}
2626

2727
{
28-
const readonlyFile = 'ro';
29-
fs.writeFileSync(readonlyFile, Buffer.alloc(0), { mode: 0o444 });
28+
const directory = 'directory';
29+
fs.mkdirSync(directory);
3030
assert.throws(() => {
31-
writeHeapSnapshot(readonlyFile);
31+
writeHeapSnapshot(directory);
3232
}, (e) => {
3333
assert.ok(e, 'writeHeapSnapshot should error');
34-
assert.strictEqual(e.code, 'EACCES');
34+
// TODO(RaisinTen): This should throw EISDIR on Windows too.
35+
assert.strictEqual(e.code,
36+
process.platform === 'win32' ? 'EACCES' : 'EISDIR');
3537
assert.strictEqual(e.syscall, 'open');
3638
return true;
3739
});

0 commit comments

Comments
 (0)