Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-inspector-debug-end.js « sequential « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f3e343a0dadb250ad46be0d4226b75efa4ed9891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const { strictEqual } = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');

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);`);
  strictEqual((await instance.expectShutdown()).exitCode, 42);
}

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);');
  strictEqual((await instance.expectShutdown()).exitCode, 42);
}

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();
  await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' });
  await session.waitForServerDisconnect();
  strictEqual((await instance.expectShutdown()).exitCode, 42);
}

async function runTest() {
  await testNoServerNoCrash();
  await testNoSessionNoCrash();
  await testSessionNoCrash();
}

runTest().then(common.mustCall());