Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix failure in test/sequential/test-heapdump.js #41772

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions test/sequential/test-heapdump.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ process.chdir(tmpdir.path);
}

{
const readonlyFile = 'ro';
fs.writeFileSync(readonlyFile, Buffer.alloc(0), { mode: 0o444 });
const directory = 'directory';
fs.mkdirSync(directory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change will keep the test content as same as before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mawaregetsuka Yes but the intention is still the same. If you go through the PR description where this was introduced - #41373, it mentions:

this PR makes v8.writeHeapSnapshot throw if the file could not be written

So the current test still attempts to recreate a scenario where the function won't be able to write to the file, so we expect it to throw.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, now I understand. That's a clever solution

assert.throws(() => {
writeHeapSnapshot(readonlyFile);
writeHeapSnapshot(directory);
}, (e) => {
assert.ok(e, 'writeHeapSnapshot should error');
assert.strictEqual(e.code, 'EACCES');
// TODO(RaisinTen): This should throw EISDIR on Windows too.
assert.strictEqual(e.code,
process.platform === 'win32' ? 'EACCES' : 'EISDIR');
assert.strictEqual(e.syscall, 'open');
return true;
});
Expand Down