| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e3f9bc8 commit 74a5e91
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ exports.start = function(argv, stdin, stdout) { | |||
| 25 | 25 | stdin = stdin || process.stdin; | |
| 26 | 26 | stdout = stdout || process.stdout; | |
| 27 | 27 | ||
| 28 | - const args = ['--debug-brk'].concat(argv); | ||
| 28 | + const args = [`--debug-brk=${exports.port}`].concat(argv); | ||
| 29 | 29 | const interface_ = new Interface(stdin, stdout, args); | |
| 30 | 30 | ||
| 31 | 31 | stdin.resume(); | |
@@ -40,7 +40,7 @@ exports.start = function(argv, stdin, stdout) { | |||
| 40 | 40 | }); | |
| 41 | 41 | }; | |
| 42 | 42 | ||
| 43 | - exports.port = 5858; | ||
| 43 | + exports.port = process.debugPort; | ||
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | 46 | // | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,41 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const path = require('path'); | ||
| 6 | + const spawn = require('child_process').spawn; | ||
| 7 | + | ||
| 8 | + const children = []; | ||
| 9 | + for (let i = 0; i < 4; i += 1) { | ||
| 10 | + const port = common.PORT + i; | ||
| 11 | + const args = [`--debug-port=${port}`, '--interactive', 'debug', __filename]; | ||
| 12 | + const child = spawn(process.execPath, args, { stdio: 'pipe' }); | ||
| 13 | + child.test = { port: port, stdout: '' }; | ||
| 14 | + child.stdout.setEncoding('utf8'); | ||
| 15 | + child.stdout.on('data', function(s) { child.test.stdout += s; update(); }); | ||
| 16 | + child.stdout.pipe(process.stdout); | ||
| 17 | + child.stderr.pipe(process.stderr); | ||
| 18 | + children.push(child); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + function update() { | ||
| 22 | + // Debugger prints relative paths except on Windows. | ||
| 23 | + const filename = path.basename(__filename); | ||
| 24 | + | ||
| 25 | + let ready = 0; | ||
| 26 | + for (const child of children) | ||
| 27 | + ready += RegExp(`break in .*?${filename}:1`).test(child.test.stdout); | ||
| 28 | + | ||
| 29 | + if (ready === children.length) | ||
| 30 | + for (const child of children) | ||
| 31 | + child.kill(); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + process.on('exit', function() { | ||
| 35 | + for (const child of children) { | ||
| 36 | + const one = RegExp(`Debugger listening on port ${child.test.port}`); | ||
| 37 | + const two = RegExp(`connecting to 127.0.0.1:${child.test.port}`); | ||
| 38 | + assert(one.test(child.test.stdout)); | ||
| 39 | + assert(two.test(child.test.stdout)); | ||
| 40 | + } | ||
| 41 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments