-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
- Loading branch information
Showing
16 changed files
with
224 additions
and
4,601 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
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,36 @@ | ||
'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) { | ||
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; | ||
} | ||
}; |
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
Oops, something went wrong.