forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-snapshot-stack-trace-limit-mutation.js
More file actions
46 lines (41 loc) · 1.33 KB
/
test-snapshot-stack-trace-limit-mutation.js
File metadata and controls
46 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
// This tests mutation to Error.stackTraceLimit in both the snapshot builder script
// and the snapshot main script work.
require('../common');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
const blobPath = tmpdir.resolve('snapshot.blob');
function test(additionalArguments = [], additionalEnv = {}) {
tmpdir.refresh();
// Check the mutation works without --stack-trace-limit.
spawnSyncAndAssert(process.execPath, [
...additionalArguments,
'--snapshot-blob',
blobPath,
'--build-snapshot',
fixtures.path('snapshot', 'mutate-error-stack-trace-limit.js'),
], {
cwd: tmpdir.path,
env: {
...process.env,
...additionalEnv,
}
}, {
stderr(output) {
assert.match(output, /Error\.stackTraceLimit has been modified by the snapshot builder script/);
assert.match(output, /It will be preserved after snapshot deserialization/);
}
});
spawnSyncAndExitWithoutError(process.execPath, [
'--snapshot-blob',
blobPath,
], {
cwd: tmpdir.path
});
}
test();
test([], { TEST_IN_SERIALIZER: 1 });
test(['--stack-trace-limit=50']);
test(['--stack-trace-limit=50'], { TEST_IN_SERIALIZER: 1 });