2017-07-24 16:23:04 +00:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const { strictEqual } = require('assert');
|
2017-10-14 02:42:38 +00:00
|
|
|
const { NodeInstance } = require('../common/inspector-helper.js');
|
2017-07-24 16:23:04 +00:00
|
|
|
|
|
|
|
async function testNoServerNoCrash() {
|
|
|
|
console.log('Test there\'s no crash stopping server that was not started');
|
|
|
|
const instance = new NodeInstance([],
|
|
|
|
`process._debugEnd();
|
|
|
|
process.exit(42);`);
|
2019-05-26 14:54:40 +00:00
|
|
|
strictEqual((await instance.expectShutdown()).exitCode, 42);
|
2017-07-24 16:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function testNoSessionNoCrash() {
|
|
|
|
console.log('Test there\'s no crash stopping server without connecting');
|
|
|
|
const instance = new NodeInstance('--inspect=0',
|
|
|
|
'process._debugEnd();process.exit(42);');
|
2019-05-26 14:54:40 +00:00
|
|
|
strictEqual((await instance.expectShutdown()).exitCode, 42);
|
2017-07-24 16:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function testSessionNoCrash() {
|
|
|
|
console.log('Test there\'s no crash stopping server after connecting');
|
|
|
|
const script = `process._debugEnd();
|
|
|
|
process._debugProcess(process.pid);
|
|
|
|
setTimeout(() => {
|
|
|
|
console.log("Done");
|
|
|
|
process.exit(42);
|
|
|
|
});`;
|
|
|
|
|
|
|
|
const instance = new NodeInstance('--inspect-brk=0', script);
|
|
|
|
const session = await instance.connectInspectorSession();
|
2024-02-23 22:46:29 +00:00
|
|
|
await session.send({ method: 'NodeRuntime.enable' });
|
|
|
|
await session.waitForNotification('NodeRuntime.waitingForDebugger');
|
2017-07-24 16:23:04 +00:00
|
|
|
await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' });
|
|
|
|
await session.waitForServerDisconnect();
|
2019-05-26 14:54:40 +00:00
|
|
|
strictEqual((await instance.expectShutdown()).exitCode, 42);
|
2017-07-24 16:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function runTest() {
|
|
|
|
await testNoServerNoCrash();
|
|
|
|
await testNoSessionNoCrash();
|
|
|
|
await testSessionNoCrash();
|
|
|
|
}
|
|
|
|
|
2020-04-05 20:27:46 +00:00
|
|
|
runTest().then(common.mustCall());
|