GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner: use v8.serialize instead of TAP · nodejs/node@da27542

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • cli.md
  • lib/internal/test_runner
    • reporter
      • v8-serializer.js
    • runner.js
    • tap_checker.js
    • tap_lexer.js
    • tap_parser.js
    • tests_stream.js
    • utils.js
    • yaml_to_js.js
  • test
    • fixtures/test-runner/output
      • arbitrary-output.js
      • arbitrary-output.snapshot
      • output_cli.snapshot
      • spec_reporter_cli.snapshot
    • parallel
      • test-runner-output.mjs
      • test-runner-reporters.js
      • test-runner-tap-checker.js
      • test-runner-tap-lexer.js
      • test-runner-tap-parser-stream.js
      • test-runner-tap-parser.js
Expand file treeCollapse file tree
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
@@ -2321,7 +2321,8 @@ on unsupported platforms will not be fixed.
23212321
### `NODE_TEST_CONTEXT=value`
23222322

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

23262327
### `NODE_TLS_REJECT_UNAUTHORIZED=value`
23272328

Collapse file

‎lib/internal/test_runner/reporter/v8-serializer.js‎

Copy file name to clipboard
+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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.