Skip to content

Commit dfea13a

Browse files
committed
test: verify inspector help url works
This commit adds basic functionality testing of the help URL printed when the inspector starts. PR-URL: #19887 Refs: #19871 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8170f4f commit dfea13a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
common.skipIfInspectorDisabled();
5+
6+
if (!common.hasCrypto)
7+
common.skip('missing crypto');
8+
9+
const assert = require('assert');
10+
const https = require('https');
11+
const { spawnSync } = require('child_process');
12+
const child = spawnSync(process.execPath, ['--inspect', '-e', '""']);
13+
const stderr = child.stderr.toString();
14+
const helpUrl = stderr.match(/For help, see: (.+)/)[1];
15+
16+
function check(url, cb) {
17+
https.get(url, common.mustCall((res) => {
18+
assert(res.statusCode >= 200 && res.statusCode < 400);
19+
20+
if (res.statusCode >= 300)
21+
return check(res.headers.location, cb);
22+
23+
let result = '';
24+
25+
res.setEncoding('utf8');
26+
res.on('data', (data) => {
27+
result += data;
28+
});
29+
30+
res.on('end', common.mustCall(() => {
31+
assert(/>Debugging Guide</.test(result));
32+
cb();
33+
}));
34+
})).on('error', common.mustNotCall);
35+
}
36+
37+
check(helpUrl, common.mustCall());

0 commit comments

Comments
 (0)