-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
19 changed files
with
303 additions
and
4,600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
const { DefaultSerializer } = require('v8'); | ||
const { Buffer } = require('buffer'); | ||
const { serializeError } = require('internal/error_serdes'); | ||
|
||
|
||
module.exports = async function* v8Reporter(source) { | ||
const serializer = new DefaultSerializer(); | ||
|
||
for await (const item of source) { | ||
const originalError = item.data.details?.error; | ||
if (originalError) { | ||
// Error is overriden with a serialized version, so that it can be | ||
// deserialized in the parent process. | ||
// Error is restored after serialization. | ||
item.data.details.error = serializeError(originalError); | ||
} | ||
// Add 4 bytes, to later populate with message length | ||
serializer.writeRawBytes(Buffer.allocUnsafe(4)); | ||
serializer.writeHeader(); | ||
serializer.writeValue(item); | ||
|
||
if (originalError) { | ||
item.data.details.error = originalError; | ||
} | ||
|
||
const serializedMessage = serializer.releaseBuffer(); | ||
const serializedMessageLength = serializedMessage.length - 4; | ||
|
||
serializedMessage.set([ | ||
serializedMessageLength >> 24 & 0xFF, | ||
serializedMessageLength >> 16 & 0xFF, | ||
serializedMessageLength >> 8 & 0xFF, | ||
serializedMessageLength & 0xFF, | ||
], 0); | ||
yield serializedMessage; | ||
} | ||
}; |
Oops, something went wrong.