test: fix flaky test-readline-interface
Move test reliant on timer triggering in a timely fahion from parallel to sequential. The test can fail under high load when the timer is triggered too late and the `\r` and `\n` are treated as separate lines. PR-URL: https://github.com/nodejs/node/pull/15066 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
c7c9e20ed0
commit
d7200d6823
@ -291,30 +291,6 @@ function isWarned(emitter) {
|
|||||||
}), delay * 2);
|
}), delay * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit one line events when the delay between \r and \n is
|
|
||||||
// over the default crlfDelay but within the setting value
|
|
||||||
{
|
|
||||||
const fi = new FakeInput();
|
|
||||||
const delay = 125;
|
|
||||||
const crlfDelay = common.platformTimeout(1000);
|
|
||||||
const rli = new readline.Interface({
|
|
||||||
input: fi,
|
|
||||||
output: fi,
|
|
||||||
terminal: terminal,
|
|
||||||
crlfDelay
|
|
||||||
});
|
|
||||||
let callCount = 0;
|
|
||||||
rli.on('line', function(line) {
|
|
||||||
callCount++;
|
|
||||||
});
|
|
||||||
fi.emit('data', '\r');
|
|
||||||
setTimeout(common.mustCall(() => {
|
|
||||||
fi.emit('data', '\n');
|
|
||||||
assert.strictEqual(callCount, 1);
|
|
||||||
rli.close();
|
|
||||||
}), delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set crlfDelay to `Infinity` is allowed
|
// set crlfDelay to `Infinity` is allowed
|
||||||
{
|
{
|
||||||
const fi = new FakeInput();
|
const fi = new FakeInput();
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
// Flags: --expose_internals
|
// Flags: --expose_internals
|
||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
// These test cases are in `sequential` rather than the analogous test file in
|
// These test cases are in `sequential` rather than the analogous test file in
|
||||||
// `parallel` because they become unrelaible under load. The unreliability under
|
// `parallel` because they become unrelaible under load. The unreliability under
|
||||||
@ -83,4 +83,28 @@ FakeInput.prototype.end = () => {};
|
|||||||
assert.strictEqual(callCount, expectedLines.length);
|
assert.strictEqual(callCount, expectedLines.length);
|
||||||
rli.close();
|
rli.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emit one line event when the delay between \r and \n is
|
||||||
|
// over the default crlfDelay but within the setting value.
|
||||||
|
{
|
||||||
|
const fi = new FakeInput();
|
||||||
|
const delay = 125;
|
||||||
|
const crlfDelay = common.platformTimeout(1000);
|
||||||
|
const rli = new readline.Interface({
|
||||||
|
input: fi,
|
||||||
|
output: fi,
|
||||||
|
terminal: terminal,
|
||||||
|
crlfDelay
|
||||||
|
});
|
||||||
|
let callCount = 0;
|
||||||
|
rli.on('line', function(line) {
|
||||||
|
callCount++;
|
||||||
|
});
|
||||||
|
fi.emit('data', '\r');
|
||||||
|
setTimeout(common.mustCall(() => {
|
||||||
|
fi.emit('data', '\n');
|
||||||
|
assert.strictEqual(callCount, 1);
|
||||||
|
rli.close();
|
||||||
|
}), delay);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user