mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
c714cda9a7
PR-URL: https://github.com/nodejs/node/pull/52132 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
// This tests that process.cwd() is accurate when
|
|
// restoring state from a snapshot
|
|
|
|
require('../common');
|
|
const { spawnSyncAndAssert } = require('../common/child_process');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const fixtures = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
|
|
tmpdir.refresh();
|
|
const blobPath = tmpdir.resolve('snapshot.blob');
|
|
const file = fixtures.path('snapshot', 'child-process-sync.js');
|
|
const expected = [
|
|
'From child process spawnSync',
|
|
'From child process execSync',
|
|
'From child process execFileSync',
|
|
];
|
|
|
|
{
|
|
// Create the snapshot.
|
|
spawnSyncAndAssert(process.execPath, [
|
|
'--snapshot-blob',
|
|
blobPath,
|
|
'--build-snapshot',
|
|
file,
|
|
], {
|
|
cwd: tmpdir.path,
|
|
}, {
|
|
trim: true,
|
|
stdout(output) {
|
|
assert.deepStrictEqual(output.split('\n'), expected);
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
|
|
{
|
|
spawnSyncAndAssert(process.execPath, [
|
|
'--snapshot-blob',
|
|
blobPath,
|
|
file,
|
|
], {
|
|
cwd: tmpdir.path,
|
|
}, {
|
|
trim: true,
|
|
stdout(output) {
|
|
assert.deepStrictEqual(output.split('\n'), expected);
|
|
return true;
|
|
}
|
|
});
|
|
}
|