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

test: fix flaky parallel/test-repl-history-navigation test #31708

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
21 changes: 8 additions & 13 deletions test/parallel/test-repl-history-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history');
// Create an input stream specialized for testing an array of actions
class ActionStream extends stream.Stream {
run(data) {
let reallyWait = true;
const _iter = data[Symbol.iterator]();
const doAction = () => {
const next = _iter.next();
Expand All @@ -34,12 +33,7 @@ class ActionStream extends stream.Stream {
} else {
this.emit('data', `${action}`);
}
if (action === WAIT && reallyWait) {
setTimeout(doAction, common.platformTimeout(50));
reallyWait = false;
} else {
setImmediate(doAction);
}
setImmediate(doAction);
};
doAction();
}
Expand Down Expand Up @@ -67,6 +61,8 @@ const WAIT = '€';

const prev = process.features.inspector;

let completions = 0;

const tests = [
{ // Creates few history to navigate for
env: { NODE_REPL_HISTORY: defaultHistoryPath },
Expand Down Expand Up @@ -435,12 +431,11 @@ const tests = [
env: { NODE_REPL_HISTORY: defaultHistoryPath },
completer(line, callback) {
if (line.endsWith(WAIT)) {
setTimeout(
callback,
common.platformTimeout(40),
null,
[[`${WAIT}WOW`], line]
);
if (completions++ === 0) {
callback(null, [[`${WAIT}WOW`], line]);
} else {
setTimeout(callback, 1000, null, [[`${WAIT}WOW`], line]).unref();
}
} else {
callback(null, [[' Always visible'], line]);
}
Expand Down