/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v26.7.0
test/sequential/test-debug-prompt.js
46 строк
1 KB
Matteo Collina
test: unflake debugger and REPL tests
05 авг 2026, 12:15
Не верифицирован
05 авг 2026, 12:15
f2919db
Код
Авторство
О чём код?
'use strict'; const common = require('../common'); common.skipIfInspectorDisabled(); const assert = require('assert'); const fixtures = require('../common/fixtures'); const spawn = require('child_process').spawn; const proc = spawn(process.execPath, [ 'inspect', fixtures.path('debugger', 'alive.js'), ]); proc.stdout.setEncoding('utf8'); const TIMEOUT = common.platformTimeout(10_000); let output = ''; let promptSeen = false; (async () => { await new Promise((resolve, reject) => { const timer = setTimeout(() => { proc.kill(); reject(new Error(`Timed out waiting for the debugger prompt; output: ${output}`)); }, TIMEOUT); proc.stdout.on('data', (data) => { output += data; if (output.includes('debug> ') && !promptSeen) { promptSeen = true; proc.stdin.end('.exit\n'); } }); proc.once('error', reject); proc.once('close', common.mustCall((code, signal) => { clearTimeout(timer); if (!promptSeen) { reject(new Error( `Debugger exited before showing the prompt (code ${code}, signal ${signal}); ` + `output: ${output}`)); return; } assert.strictEqual(code, 0); resolve(); })); }); })().then(common.mustCall());