• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3common.skipIfInspectorDisabled();
4const { strictEqual } = require('assert');
5const { NodeInstance } = require('../common/inspector-helper.js');
6
7async function testNoServerNoCrash() {
8  console.log('Test there\'s no crash stopping server that was not started');
9  const instance = new NodeInstance([],
10                                    `process._debugEnd();
11                                     process.exit(42);`);
12  strictEqual((await instance.expectShutdown()).exitCode, 42);
13}
14
15async function testNoSessionNoCrash() {
16  console.log('Test there\'s no crash stopping server without connecting');
17  const instance = new NodeInstance('--inspect=0',
18                                    'process._debugEnd();process.exit(42);');
19  strictEqual((await instance.expectShutdown()).exitCode, 42);
20}
21
22async function testSessionNoCrash() {
23  console.log('Test there\'s no crash stopping server after connecting');
24  const script = `process._debugEnd();
25                  process._debugProcess(process.pid);
26                  setTimeout(() => {
27                      console.log("Done");
28                      process.exit(42);
29                  });`;
30
31  const instance = new NodeInstance('--inspect-brk=0', script);
32  const session = await instance.connectInspectorSession();
33  await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' });
34  await session.waitForServerDisconnect();
35  strictEqual((await instance.expectShutdown()).exitCode, 42);
36}
37
38async function runTest() {
39  await testNoServerNoCrash();
40  await testNoSessionNoCrash();
41  await testSessionNoCrash();
42}
43
44runTest().then(common.mustCall());
45