Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: add emitClose: true tests for fs streams
  • Loading branch information
Trott committed Aug 22, 2019
commit 93c1f17ec2861d602b263b9450d19b127873d9fa
27 changes: 25 additions & 2 deletions test/parallel/test-fs-stream-destroy-emit-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,31 @@ const fs = require('fs');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

test(fs.createReadStream(__filename));
test(fs.createWriteStream(`${tmpdir.path}/dummy`));
{
const stream = fs.createReadStream(__filename);
stream.on('close', common.mustNotCall());
test(stream);
}

{
const stream = fs.createWriteStream(`${tmpdir.path}/dummy`);
stream.on('close', common.mustNotCall());
test(stream);
}

{
const stream = fs.createReadStream(__filename, { emitClose: true });
stream.on('close', common.mustCall());
test(stream);
}

{
const stream = fs.createWriteStream(`${tmpdir.path}/dummy2`,
{ emitClose: true });
stream.on('close', common.mustCall());
test(stream);
}


function test(stream) {
const err = new Error('DESTROYED');
Expand Down