mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Signed-off-by: parkhojeong <parkhj062@gmail.com> PR-URL: https://github.com/nodejs/node/pull/63403 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
// Tests creating workers after snapshot deserialization works
|
|
// in embedded environments.
|
|
|
|
const common = require('../common');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const {
|
|
spawnSyncAndAssert,
|
|
spawnSyncAndExitWithoutError,
|
|
} = require('../common/child_process');
|
|
|
|
const snapshotFixture = fixtures.path('snapshot', 'create-worker.js');
|
|
const embedtest = common.resolveBuiltBinary('embedtest');
|
|
|
|
const buildSnapshotExecArgs = [
|
|
`eval(require("fs").readFileSync(${JSON.stringify(snapshotFixture)}, "utf8"))`,
|
|
'arg1', 'arg2',
|
|
];
|
|
const snapshotBlobArgs = [
|
|
'--embedder-snapshot-blob', tmpdir.resolve('embedder-snapshot.blob'),
|
|
];
|
|
|
|
const runSnapshotExecArgs = ['arg3', 'arg4'];
|
|
|
|
tmpdir.refresh();
|
|
|
|
// Build the snapshot with the worker-creating code in serialized main function.
|
|
spawnSyncAndExitWithoutError(
|
|
embedtest,
|
|
['--', ...buildSnapshotExecArgs, ...snapshotBlobArgs, '--embedder-snapshot-create'],
|
|
{ cwd: tmpdir.path });
|
|
|
|
// Run the snapshot that creates a worker from the snapshot.
|
|
spawnSyncAndAssert(
|
|
embedtest,
|
|
['--', ...runSnapshotExecArgs, ...snapshotBlobArgs ],
|
|
{ cwd: tmpdir.path },
|
|
{
|
|
stdout: /value: 42/,
|
|
});
|