Skip to content

Commit

Permalink
try to make the interactive test less flaky
Browse files Browse the repository at this point in the history
It seems like it's not getting the last item sometimes,
because the readline doesn't see it in time, or something.

Just keep repeating the last entry if it asks again.
  • Loading branch information
isaacs committed Mar 4, 2023
1 parent 38e731f commit 95e13f2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,18 @@ t.test('interactive deletes', t => {
}, 10000)
child.stdout.setEncoding('utf8')
child.stderr.setEncoding('utf8')
let last = ''
child.stdout.on('data', async c => {
await new Promise(r => setTimeout(r, 50))
out.push(c.trim())
const s = script.shift()
if (s !== undefined) {
last === s
out.push(s.trim())
child.stdin.write(s + '\n')
} else {
// keep writing whatever the last option was
child.stdin.write(last + '\n')
}
})
child.stderr.on('data', c => {
Expand Down

0 comments on commit 95e13f2

Please sign in to comment.