summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2016-06-29 23:20:06 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2016-09-23 18:51:47 +0200
commit782620f03ffcaa5be9e84f8f15a638cb7c03e464 (patch)
treee1eef1626561518a5e8afd151281146a4706de9a /test
parenta8d2c9d7750f05ae78b6b6b8de3c3161c7f6270e (diff)
downloadandroid-node-v8-782620f03ffcaa5be9e84f8f15a638cb7c03e464.tar.gz
android-node-v8-782620f03ffcaa5be9e84f8f15a638cb7c03e464.tar.bz2
android-node-v8-782620f03ffcaa5be9e84f8f15a638cb7c03e464.zip
src: add /json/protocol endpoint to inspector
Embed the compressed and minified protocol.json from the bundled v8_inspector and make it available through the /json/protocol endpoint. Refs: https://github.com/nodejs/diagnostics/issues/52 PR-URL: https://github.com/nodejs/node/pull/7491 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/common.js1
-rw-r--r--test/parallel/test-v8-inspector-json-protocol.js22
-rw-r--r--test/testpy/__init__.py5
3 files changed, 27 insertions, 1 deletions
diff --git a/test/common.js b/test/common.js
index a5094b1d43..5a9369f196 100644
--- a/test/common.js
+++ b/test/common.js
@@ -16,6 +16,7 @@ exports.testDir = __dirname;
exports.fixturesDir = path.join(exports.testDir, 'fixtures');
exports.libDir = path.join(exports.testDir, '../lib');
exports.tmpDirName = 'tmp';
+// PORT should match the definition in test/testpy/__init__.py.
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
exports.isWindows = process.platform === 'win32';
exports.isWOW64 = exports.isWindows &&
diff --git a/test/parallel/test-v8-inspector-json-protocol.js b/test/parallel/test-v8-inspector-json-protocol.js
new file mode 100644
index 0000000000..762c4386bb
--- /dev/null
+++ b/test/parallel/test-v8-inspector-json-protocol.js
@@ -0,0 +1,22 @@
+// Flags: --inspect={PORT}
+'use strict';
+
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+
+const options = {
+ path: '/json/protocol',
+ port: common.PORT,
+ host: common.localhostIPv4,
+};
+
+http.get(options, common.mustCall((res) => {
+ let body = '';
+ res.setEncoding('utf8');
+ res.on('data', (data) => body += data);
+ res.on('end', common.mustCall(() => {
+ assert(body.length > 0);
+ assert.deepStrictEqual(JSON.stringify(JSON.parse(body)), body);
+ }));
+}));
diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py
index 9fff0b969c..367346f6e1 100644
--- a/test/testpy/__init__.py
+++ b/test/testpy/__init__.py
@@ -61,7 +61,10 @@ class SimpleTestCase(test.TestCase):
source = open(self.file).read()
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
- result += flags_match.group(1).strip().split()
+ # PORT should match the definition in test/common.js.
+ env = { 'PORT': int(os.getenv('NODE_COMMON_PORT', '12346')) }
+ env['PORT'] += self.thread_id * 100
+ result += flags_match.group(1).strip().format(**env).split()
files_match = FILES_PATTERN.search(source);
additional_files = []
if files_match: