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

changed var to const, added strict equality checks #8762

Closed
wants to merge 1 commit into from
Closed
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
33 changes: 19 additions & 14 deletions test/parallel/test-fs-read-stream-fd-leak.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';

var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var path = require('path');
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');

var openCount = 0;
var _fsopen = fs.open;
var _fsclose = fs.close;
const _fsopen = fs.open;
const _fsclose = fs.close;

var loopCount = 50;
var totalCheck = 50;
var emptyTxt = path.join(common.fixturesDir, 'empty.txt');
const loopCount = 50;
const totalCheck = 50;
const emptyTxt = path.join(common.fixturesDir, 'empty.txt');

fs.open = function() {
openCount++;
Expand All @@ -29,20 +29,25 @@ function testLeak(endFn, callback) {
var i = 0;
var check = 0;

var checkFunction = function() {
if (openCount != 0 && check < totalCheck) {
const checkFunction = function() {
if (openCount !== 0 && check < totalCheck) {
check++;
setTimeout(checkFunction, 100);
return;
}
assert.equal(0, openCount, 'no leaked file descriptors using ' +
endFn + '() (got ' + openCount + ')');

assert.strictEqual(
0,
openCount,
`no leaked file descriptors using ${endFn}() (got ${openCount})`
);

openCount = 0;
callback && setTimeout(callback, 100);
};

setInterval(function() {
var s = fs.createReadStream(emptyTxt);
const s = fs.createReadStream(emptyTxt);
s[endFn]();

if (++i === loopCount) {
Expand Down