mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
e738edce6a
Subsystems: blob, child_process, common, crypto, http, http2, readline, repl, snapshot, trace_events PR-URL: https://github.com/nodejs/node/pull/49127 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
// This tests the console works in the deserialized snapshot.
|
|
|
|
const common = require('../common');
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const fixtures = require('../common/fixtures');
|
|
const fs = require('fs');
|
|
|
|
tmpdir.refresh();
|
|
const blobPath = tmpdir.resolve('snapshot.blob');
|
|
const entry = fixtures.path('snapshot', 'console.js');
|
|
|
|
{
|
|
const child = spawnSync(process.execPath, [
|
|
'--snapshot-blob',
|
|
blobPath,
|
|
'--build-snapshot',
|
|
entry,
|
|
], {
|
|
cwd: tmpdir.path
|
|
});
|
|
const stdout = child.stdout.toString();
|
|
if (child.status !== 0) {
|
|
console.log(stdout);
|
|
console.log(child.stderr.toString());
|
|
assert.strictEqual(child.status, 0);
|
|
}
|
|
assert.deepStrictEqual(Object.keys(console), JSON.parse(stdout));
|
|
const stats = fs.statSync(tmpdir.resolve('snapshot.blob'));
|
|
assert(stats.isFile());
|
|
}
|
|
|
|
{
|
|
const child = spawnSync(process.execPath, [
|
|
'--snapshot-blob',
|
|
blobPath,
|
|
], {
|
|
cwd: tmpdir.path,
|
|
env: {
|
|
...process.env,
|
|
}
|
|
});
|
|
|
|
const stdout = child.stdout.toString();
|
|
if (child.status !== 0) {
|
|
console.log(stdout);
|
|
console.log(child.stderr.toString());
|
|
assert.strictEqual(child.status, 0);
|
|
}
|
|
assert.deepStrictEqual(Object.keys(console), JSON.parse(stdout));
|
|
assert.strictEqual(child.status, 0);
|
|
}
|