Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bdca468

Browse filesBrowse files
committed
test_runner: use v8.serialize instead of TAP
PR-URL: #47867 Fixes: #44656 Fixes: #47955 Fixes: #47481 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 13bc548 commit bdca468
Copy full SHA for bdca468
Expand file treeCollapse file tree

19 files changed

+303
-4600
lines changed
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+2-1Lines changed: 2 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,8 @@ on unsupported platforms will not be fixed.
20692069
### `NODE_TEST_CONTEXT=value`
20702070

20712071
If `value` equals `'child'`, test reporter options will be overridden and test
2072-
output will be sent to stdout in the TAP format.
2072+
output will be sent to stdout in the TAP format. If any other value is provided,
2073+
Node.js makes no guarantees about the reporter format used or its stability.
20732074

20742075
### `NODE_TLS_REJECT_UNAUTHORIZED=value`
20752076

Collapse file
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
const { DefaultSerializer } = require('v8');
4+
const { Buffer } = require('buffer');
5+
const { serializeError } = require('internal/error_serdes');
6+
7+
8+
module.exports = async function* v8Reporter(source) {
9+
const serializer = new DefaultSerializer();
10+
11+
for await (const item of source) {
12+
const originalError = item.data.details?.error;
13+
if (originalError) {
14+
// Error is overriden with a serialized version, so that it can be
15+
// deserialized in the parent process.
16+
// Error is restored after serialization.
17+
item.data.details.error = serializeError(originalError);
18+
}
19+
// Add 4 bytes, to later populate with message length
20+
serializer.writeRawBytes(Buffer.allocUnsafe(4));
21+
serializer.writeHeader();
22+
serializer.writeValue(item);
23+
24+
if (originalError) {
25+
item.data.details.error = originalError;
26+
}
27+
28+
const serializedMessage = serializer.releaseBuffer();
29+
const serializedMessageLength = serializedMessage.length - 4;
30+
31+
serializedMessage.set([
32+
serializedMessageLength >> 24 & 0xFF,
33+
serializedMessageLength >> 16 & 0xFF,
34+
serializedMessageLength >> 8 & 0xFF,
35+
serializedMessageLength & 0xFF,
36+
], 0);
37+
yield serializedMessage;
38+
}
39+
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.