test_runner: use v8.serialize instead of TAP#47867
test_runner: use v8.serialize instead of TAP#47867nodejs-github-bot merged 6 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
cjihrig
left a comment
There was a problem hiding this comment.
Left some comments. The only thing I'm really concerned about is some of the changes in test/fixtures/test-runner/output/spec_reporter_cli.snapshot. You should also share the performance gains you shared with me on Slack 😄
cjihrig
left a comment
There was a problem hiding this comment.
Requesting changes just so that this doesn't land yet now that there is an approval.
Well - this is kind of a good thing since most of the changes reduce the delta between running with and without (remember spec reporter includes each failing test twice when looking at this diff :)) diff --git a/test/fixtures/test-runner/output/spec_reporter_cli.js b/test/fixtures/test-runner/output/spec_reporter_cli.js
index e88a7221fb..6a7c2d655f 100644
--- a/test/fixtures/test-runner/output/spec_reporter_cli.js
+++ b/test/fixtures/test-runner/output/spec_reporter_cli.js
@@ -5,7 +5,7 @@ const fixtures = require('../../../common/fixtures');
const spawn = require('node:child_process').spawn;
const child = spawn(process.execPath,
- ['--no-warnings', '--test', '--test-reporter', 'spec', fixtures.path('test-runner/output/output.js')],
+ ['--no-warnings', '--test-reporter', 'spec', fixtures.path('test-runner/output/output.js')],
{ stdio: 'pipe' });
// eslint-disable-next-line no-control-regex
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '')));
diff --git a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot
index a8a628e1e1..7682041770 100644
--- a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot
+++ b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot
@@ -109,7 +109,7 @@
subtest sync throw fail (*ms)
sync throw non-error fail (*ms)
- 'Symbol(thrown symbol from sync throw non-error fail)'
+ Symbol(thrown symbol from sync throw non-error fail)
level 0a
level 1a (*ms)
@@ -185,8 +185,8 @@
Error [ERR_TEST_FAILURE]: callback invoked multiple times
* {
failureType: 'multipleCallbackInvocations',
- code: 'ERR_TEST_FAILURE',
- [cause]: 'callback invoked multiple times'
+ cause: 'callback invoked multiple times',
+ code: 'ERR_TEST_FAILURE'
}
callback async throw (*ms)
@@ -206,10 +206,10 @@
'only' and 'runOnly' require the --test-only command-line option.
custom inspect symbol fail (*ms)
- { foo: 1 }
+ customized
custom inspect symbol that throws fail (*ms)
- { foo: 1 }
+ { foo: 1, [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] }
subtest sync throw fails
sync throw fails at first (*ms)
@@ -281,8 +281,8 @@
* {
generatedMessage: true,
code: 'ERR_ASSERTION',
- actual: { foo: 1, bar: 1 },
- expected: <ref *1> { bar: 2, c: [Circular *1] },
+ actual: [Object],
+ expected: [Object],
operator: 'deepEqual'
}
@@ -400,7 +400,7 @@
*
sync throw non-error fail (*ms)
- 'Symbol(thrown symbol from sync throw non-error fail)'
+ Symbol(thrown symbol from sync throw non-error fail)
+long running (*ms)
'test did not finish before its parent and was cancelled'
@@ -440,8 +440,8 @@
Error [ERR_TEST_FAILURE]: callback invoked multiple times
* {
failureType: 'multipleCallbackInvocations',
- code: 'ERR_TEST_FAILURE',
- [cause]: 'callback invoked multiple times'
+ cause: 'callback invoked multiple times',
+ code: 'ERR_TEST_FAILURE'
}
callback async throw (*ms)
@@ -450,10 +450,10 @@
*
custom inspect symbol fail (*ms)
- { foo: 1 }
+ customized
custom inspect symbol that throws fail (*ms)
- { foo: 1 }
+ { foo: 1, [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] }
sync throw fails at first (*ms)
Error: thrown from subtest sync throw fails at first
@@ -519,8 +519,8 @@
* {
generatedMessage: true,
code: 'ERR_ASSERTION',
- actual: { foo: 1, bar: 1 },
- expected: <ref *1> { bar: 2, c: [Circular *1] },
+ actual: [Object],
+ expected: [Object],
operator: 'deepEqual'
}
Sure! I tried later on and it seemed like there is not always such a good performance gain - it really depends on the suite you run. |
d9c12f8 to
cb71d5c
Compare
|
now there almost no delta between with and without |
Thanks for clarifying. That's good news. |
cb71d5c to
4f92f53
Compare
b0698ed to
7990e81
Compare
cjihrig
left a comment
There was a problem hiding this comment.
The changes in lib/internal/error_serdes.js should be in a separate commit, and arguably a separate PR, and with approval from @nodejs/workers
cjihrig
left a comment
There was a problem hiding this comment.
The changes in lib/internal/error_serdes.js should be in a separate commit, and arguably a separate PR, and with approval from @nodejs/workers
lib/internal/test_runner/runner.js
Outdated
|
|
||
| // Index 0 should always be present because we just pushed data into it. | ||
| let messageBufferHead = this.#messageBuffer[0]; | ||
| let headerIndex = messageBufferHead.indexOf(v8Header); |
There was a problem hiding this comment.
| let headerIndex = messageBufferHead.indexOf(v8Header); | |
| let headerIndex = ArrayPrototypeIndexOf(messageBufferHead, v8Header); |
There was a problem hiding this comment.
messageBufferHead is a Buffer
There was a problem hiding this comment.
If it's a Buffer, you should be able to use Uint8ArrayPrototypeIndexOf
There was a problem hiding this comment.
I have tried but:
./node --expose-internals -p "require('internal/test/binding').primordials.Uint8ArrayPrototypeIndexOf()" results in require(...).primordials.Uint8ArrayPrototypeIndexOf is not a function
and
./node --expose-internals -p "require('internal/test/binding').primordials.TypedArrayPrototypeIndexOf(Buffer.from('Hello'), Buffer.from('ll'))"results in -1
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
| process.stdout.write(Buffer.from("arbitrary - mid")); | ||
| process.stdout.write(Buffer.concat([chunk, Buffer.from("arbitrary - post")])); | ||
| } | ||
| })(); |
There was a problem hiding this comment.
Should we have a .then(common.mustCall()) here?
There was a problem hiding this comment.
no need, we snapshot the output
| // Flags: --test --expose-internals | ||
| 'use strict'; | ||
|
|
||
| const v8_reporter = require('internal/test_runner/reporter/v8-serializer'); |
There was a problem hiding this comment.
| const v8_reporter = require('internal/test_runner/reporter/v8-serializer'); | |
| const v8Reporter = require('internal/test_runner/reporter/v8-serializer'); |
There was a problem hiding this comment.
if this is the only comment, Il skip it :)
|
Landed in 7116bc0 |
|
note: if backported, please backport along with #48106 |
PR-URL: nodejs#47867 Fixes: nodejs#44656 Fixes: nodejs#47955 Fixes: nodejs#47481 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Refs: #47663 (comment)
Fixes: #44656
Fixes: #47955
Fixes: #47481
not sure if this change is something we desire to document.