From dfea13a1688f8fda6a7132714019067e7da68d1b Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 8 Apr 2018 22:54:24 -0400 Subject: [PATCH] test: verify inspector help url works This commit adds basic functionality testing of the help URL printed when the inspector starts. PR-URL: https://github.com/nodejs/node/pull/19887 Refs: https://github.com/nodejs/node/pull/19871 Reviewed-By: Rich Trott Reviewed-By: Richard Lau Reviewed-By: Khaidi Chu Reviewed-By: Trivikram Kamat Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- test/internet/test-inspector-help-page.js | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/internet/test-inspector-help-page.js diff --git a/test/internet/test-inspector-help-page.js b/test/internet/test-inspector-help-page.js new file mode 100644 index 00000000000000..a6a38bd0265e78 --- /dev/null +++ b/test/internet/test-inspector-help-page.js @@ -0,0 +1,37 @@ +'use strict'; +const common = require('../common'); + +common.skipIfInspectorDisabled(); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const https = require('https'); +const { spawnSync } = require('child_process'); +const child = spawnSync(process.execPath, ['--inspect', '-e', '""']); +const stderr = child.stderr.toString(); +const helpUrl = stderr.match(/For help, see: (.+)/)[1]; + +function check(url, cb) { + https.get(url, common.mustCall((res) => { + assert(res.statusCode >= 200 && res.statusCode < 400); + + if (res.statusCode >= 300) + return check(res.headers.location, cb); + + let result = ''; + + res.setEncoding('utf8'); + res.on('data', (data) => { + result += data; + }); + + res.on('end', common.mustCall(() => { + assert(/>Debugging Guide