mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test: fix flaky test-debug-port
It can happen that first data chunk received in stdout is not exactly `'debug> '`. Make sure the exit condition is met. PR-URL: https://github.com/nodejs/node/pull/10316 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit is contained in:
1 file changed
+7
-6
@@ -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();
|
||||
});
|
||||
Reference in new issue
Block a user