Skip to content

[v8.x] test: remove orphaned entries from status #19043

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions benchmark/misc/punycode.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
'use strict';

const common = require('../common.js');
const icu = process.binding('icu');
let icu;
try {
icu = process.binding('icu');
} catch (err) {}
const punycode = require('punycode');

const bench = common.createBenchmark(main, {
method: ['punycode', 'icu'],
method: ['punycode'].concat(icu !== undefined ? ['icu'] : []),
n: [1024],
val: [
'افغانستا.icom.museum',
Expand Down Expand Up @@ -69,8 +72,11 @@ function main(conf) {
runPunycode(n, val);
break;
case 'icu':
runICU(n, val);
break;
if (icu !== undefined) {
runICU(n, val);
break;
}
// fallthrough
default:
throw new Error('Unexpected method');
}
Expand Down
11 changes: 9 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1950,8 +1950,7 @@ function ReadStream(path, options) {
this.flags = options.flags === undefined ? 'r' : options.flags;
this.mode = options.mode === undefined ? 0o666 : options.mode;

this.start = typeof this.fd !== 'number' && options.start === undefined ?
0 : options.start;
this.start = options.start;
this.end = options.end;
this.autoClose = options.autoClose === undefined ? true : options.autoClose;
this.pos = undefined;
Expand All @@ -1974,6 +1973,12 @@ function ReadStream(path, options) {
this.pos = this.start;
}

// Backwards compatibility: Make sure `end` is a number regardless of `start`.
// TODO(addaleax): Make the above typecheck not depend on `start` instead.
// (That is a semver-major change).
if (typeof this.end !== 'number')
this.end = Infinity;

if (typeof this.fd !== 'number')
this.open();

Expand Down Expand Up @@ -2028,6 +2033,8 @@ ReadStream.prototype._read = function(n) {

if (this.pos !== undefined)
toRead = Math.min(this.end - this.pos + 1, toRead);
else
toRead = Math.min(this.end - this.bytesRead + 1, toRead);

// already read everything we were supposed to read!
// treat as EOF.
Expand Down
2 changes: 0 additions & 2 deletions test/known_issues/known_issues.status
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ prefix known_issues
[true] # This section applies to all platforms

[$system==win32]
test-stdout-buffer-flush-on-exit: SKIP
test-cluster-disconnect-handles: SKIP

[$system==linux]

Expand Down
26 changes: 26 additions & 0 deletions test/parallel/test-fs-read-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'use strict';
const common = require('../common');

const child_process = require('child_process');
const assert = require('assert');
const fs = require('fs');
const fixtures = require('../common/fixtures');
Expand Down Expand Up @@ -171,6 +172,31 @@ assert.throws(function() {
}));
}

if (!common.isWindows) {
// Verify that end works when start is not specified, and we do not try to
// use positioned reads. This makes sure that this keeps working for
// non-seekable file descriptors.
common.refreshTmpDir();
const filename = `${common.tmpDir}/foo.pipe`;
const mkfifoResult = child_process.spawnSync('mkfifo', [filename]);
if (!mkfifoResult.error) {
child_process.exec(`echo "xyz foobar" > '${filename}'`);
const stream = new fs.createReadStream(filename, { end: 1 });
stream.data = '';

stream.on('data', function(chunk) {
stream.data += chunk;
});

stream.on('end', common.mustCall(function() {
assert.strictEqual('xy', stream.data);
fs.unlinkSync(filename);
}));
} else {
common.printSkipMessage('mkfifo not available');
}
}

{
// pause and then resume immediately.
const pauseRes = fs.createReadStream(rangeFile);
Expand Down