Skip to content

Commit

Permalink
test: fix flaky test-debug-port
Browse files Browse the repository at this point in the history
It can happen that first data chunk received in stdout is not exactly
`'debug> '`. Make sure the exit condition is met.

PR-URL: #10316
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Italo A. Casas <[email protected]>
  • Loading branch information
santigimeno committed Dec 19, 2016
1 parent 5d14602 commit 793d871
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/parallel/test-debug-prompt.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';

const assert = require('assert');
const common = require('../common');
require('../common');
const spawn = require('child_process').spawn;

const proc = spawn(process.execPath, ['debug', 'foo']);
proc.stdout.setEncoding('utf8');

proc.stdout.once('data', common.mustCall((data) => {
assert.strictEqual(data, 'debug> ');
proc.kill();
}));
let output = '';
proc.stdout.on('data', (data) => {
output += data;
if (output.includes('debug> '))
proc.kill();
});

0 comments on commit 793d871

Please sign in to comment.