Skip to content

Commit 1f88ca3

Browse files
TrottBridgeAR
authored andcommitted
test: add emitClose: true tests for fs streams
PR-URL: #29212 Fixes: #29177 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 8f47ff1 commit 1f88ca3

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

test/parallel/test-fs-stream-destroy-emit-error.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,31 @@ const fs = require('fs');
66
const tmpdir = require('../common/tmpdir');
77
tmpdir.refresh();
88

9-
test(fs.createReadStream(__filename));
10-
test(fs.createWriteStream(`${tmpdir.path}/dummy`));
9+
{
10+
const stream = fs.createReadStream(__filename);
11+
stream.on('close', common.mustNotCall());
12+
test(stream);
13+
}
14+
15+
{
16+
const stream = fs.createWriteStream(`${tmpdir.path}/dummy`);
17+
stream.on('close', common.mustNotCall());
18+
test(stream);
19+
}
20+
21+
{
22+
const stream = fs.createReadStream(__filename, { emitClose: true });
23+
stream.on('close', common.mustCall());
24+
test(stream);
25+
}
26+
27+
{
28+
const stream = fs.createWriteStream(`${tmpdir.path}/dummy2`,
29+
{ emitClose: true });
30+
stream.on('close', common.mustCall());
31+
test(stream);
32+
}
33+
1134

1235
function test(stream) {
1336
const err = new Error('DESTROYED');

0 commit comments

Comments
 (0)