mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
65fbc95949
Previously, --trace-exit and --trace-sync-io doesn't take care of --stack-trace-limit and always print a stack trace with maximum size of 10. This patch parses --stack-trace-limit during initialization and use the value in --trace-* flags. PR-URL: https://github.com/nodejs/node/pull/55121 Fixes: https://github.com/nodejs/node/issues/55100 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
// This tests that --stack-trace-limit can be used to tweak the stack trace size of --trace-exit.
|
|
require('../common');
|
|
const fixture = require('../common/fixtures');
|
|
const { spawnSyncAndAssert } = require('../common/child_process');
|
|
const assert = require('assert');
|
|
|
|
// When the stack trace limit is bigger than the stack trace size, it should output them all.
|
|
spawnSyncAndAssert(
|
|
process.execPath,
|
|
['--trace-exit', '--stack-trace-limit=50', fixture.path('deep-exit.js')],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
STACK_DEPTH: 30
|
|
}
|
|
},
|
|
{
|
|
stderr(output) {
|
|
const matches = [...output.matchAll(/at recurse/g)];
|
|
assert.strictEqual(matches.length, 30);
|
|
}
|
|
});
|
|
|
|
// When the stack trace limit is smaller than the stack trace size, it should truncate the stack size.
|
|
spawnSyncAndAssert(
|
|
process.execPath,
|
|
['--trace-exit', '--stack-trace-limit=30', fixture.path('deep-exit.js')],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
STACK_DEPTH: 30
|
|
}
|
|
},
|
|
{
|
|
stderr(output) {
|
|
const matches = [...output.matchAll(/at recurse/g)];
|
|
// The top frame is process.exit(), so one frame from recurse() is truncated.
|
|
assert.strictEqual(matches.length, 29);
|
|
}
|
|
});
|