GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: test syncrhnous methods of child_process in snapshot · nodejs/node@aee01ff

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • fixtures/snapshot
      • child-process-sync.js
    • parallel
      • test-snapshot-child-process-sync.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/fixtures/snapshot/child-process-sync.js‎

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
const {
4+
setDeserializeMainFunction,
5+
isBuildingSnapshot
6+
} = require('v8').startupSnapshot;
7+
8+
function spawn() {
9+
const { spawnSync, execFileSync, execSync } = require('child_process');
10+
spawnSync(process.execPath, [ __filename, 'spawnSync' ], { stdio: 'inherit' });
11+
execSync(`"${process.execPath}" "${__filename}" "execSync"`, { stdio: 'inherit' });
12+
execFileSync(process.execPath, [ __filename, 'execFileSync' ], { stdio: 'inherit' });
13+
}
14+
15+
if (process.argv[2] !== undefined) {
16+
console.log('From child process', process.argv[2]);
17+
} else {
18+
spawn();
19+
}
20+
21+
if (isBuildingSnapshot()) {
22+
setDeserializeMainFunction(() => {
23+
spawn();
24+
});
25+
}
Collapse file

‎test/parallel/test-snapshot-child-process-sync.js‎

Copy file name to clipboard
+53Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
// This tests that process.cwd() is accurate when
4+
// restoring state from a snapshot
5+
6+
require('../common');
7+
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
8+
const tmpdir = require('../common/tmpdir');
9+
const fixtures = require('../common/fixtures');
10+
const assert = require('assert');
11+
12+
tmpdir.refresh();
13+
const blobPath = tmpdir.resolve('snapshot.blob');
14+
const file = fixtures.path('snapshot', 'child-process-sync.js');
15+
const expected = [
16+
'From child process spawnSync',
17+
'From child process execSync',
18+
'From child process execFileSync',
19+
];
20+
21+
{
22+
// Create the snapshot.
23+
spawnSyncAndExitWithoutError(process.execPath, [
24+
'--snapshot-blob',
25+
blobPath,
26+
'--build-snapshot',
27+
file,
28+
], {
29+
cwd: tmpdir.path,
30+
}, {
31+
trim: true,
32+
stdout(output) {
33+
assert.deepStrictEqual(output.split('\n'), expected);
34+
return true;
35+
}
36+
});
37+
}
38+
39+
{
40+
spawnSyncAndExitWithoutError(process.execPath, [
41+
'--snapshot-blob',
42+
blobPath,
43+
file,
44+
], {
45+
cwd: tmpdir.path,
46+
}, {
47+
trim: true,
48+
stdout(output) {
49+
assert.deepStrictEqual(output.split('\n'), expected);
50+
return true;
51+
}
52+
});
53+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.