GeezerVison is showing github.com — test: use spawnSyncAndExitWithoutError in sea tests · nodejs/node@3599eeb
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/sequential/test-single-executable-application-snapshot-and-code-cache.js +13-8Lines changed: 13 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,9 @@ skipIfSingleExecutableIsNotSupported(); | 13 | 13 |
| 14 | 14 | const tmpdir = require('../common/tmpdir'); | 15 | 15 | const { copyFileSync, writeFileSync, existsSync } = require('fs'); | 16 | | -const { spawnSync } = require('child_process'); | | 16 | +const { | | 17 | + spawnSyncAndExitWithoutError | | 18 | +} = require('../common/child_process'); | 17 | 19 | const { join } = require('path'); | 18 | 20 | const assert = require('assert'); | 19 | 21 |
| @@ -43,21 +45,24 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : | 43 | 45 | } | 44 | 46 | `); | 45 | 47 |
| 46 | | - let child = spawnSync( | | 48 | + spawnSyncAndExitWithoutError( | 47 | 49 | process.execPath, | 48 | 50 | ['--experimental-sea-config', 'sea-config.json'], | 49 | 51 | { | 50 | 52 | cwd: tmpdir.path | 51 | | - }); | 52 | | - assert.match( | 53 | | - child.stderr.toString(), | 54 | | - /"useCodeCache" is redundant when "useSnapshot" is true/); | | 53 | + }, | | 54 | + { | | 55 | + stderr: /"useCodeCache" is redundant when "useSnapshot" is true/ | | 56 | + } | | 57 | + ); | 55 | 58 |
| 56 | 59 | assert(existsSync(seaPrepBlob)); | 57 | 60 |
| 58 | 61 | copyFileSync(process.execPath, outputFile); | 59 | 62 | injectAndCodeSign(outputFile, seaPrepBlob); | 60 | 63 |
| 61 | | - child = spawnSync(outputFile); | 62 | | - assert.strictEqual(child.stdout.toString().trim(), 'Hello from snapshot'); | | 64 | + spawnSyncAndExitWithoutError(outputFile, { | | 65 | + stdout: 'Hello from snapshot', | | 66 | + trim: true, | | 67 | + }); | 63 | 68 | } |
Collapse file Copy file name to clipboardExpand all lines: test/sequential/test-single-executable-application-snapshot.js +26-15Lines changed: 26 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,10 @@ skipIfSingleExecutableIsNotSupported(); | 13 | 13 |
| 14 | 14 | const tmpdir = require('../common/tmpdir'); | 15 | 15 | const { copyFileSync, writeFileSync, existsSync } = require('fs'); | 16 | | -const { spawnSync } = require('child_process'); | | 16 | +const { | | 17 | + spawnSyncAndExit, | | 18 | + spawnSyncAndExitWithoutError | | 19 | +} = require('../common/child_process'); | 17 | 20 | const assert = require('assert'); | 18 | 21 |
| 19 | 22 | const configFile = tmpdir.resolve('sea-config.json'); | @@ -32,16 +35,17 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se | 32 | 35 | } | 33 | 36 | `); | 34 | 37 |
| 35 | | - const child = spawnSync( | | 38 | + spawnSyncAndExit( | 36 | 39 | process.execPath, | 37 | 40 | ['--experimental-sea-config', 'sea-config.json'], | 38 | 41 | { | 39 | 42 | cwd: tmpdir.path | | 43 | + }, | | 44 | + { | | 45 | + status: 1, | | 46 | + signal: null, | | 47 | + stderr: /snapshot\.js does not invoke v8\.startupSnapshot\.setDeserializeMainFunction\(\)/ | 40 | 48 | }); | 41 | | - | 42 | | - assert.match( | 43 | | - child.stderr.toString(), | 44 | | - /snapshot\.js does not invoke v8\.startupSnapshot\.setDeserializeMainFunction\(\)/); | 45 | 49 | } | 46 | 50 |
| 47 | 51 | { | @@ -65,24 +69,31 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se | 65 | 69 | } | 66 | 70 | `); | 67 | 71 |
| 68 | | - let child = spawnSync( | | 72 | + spawnSyncAndExitWithoutError( | 69 | 73 | process.execPath, | 70 | 74 | ['--experimental-sea-config', 'sea-config.json'], | 71 | 75 | { | 72 | 76 | cwd: tmpdir.path | | 77 | + }, | | 78 | + { | | 79 | + stderr: /Single executable application is an experimental feature/ | 73 | 80 | }); | 74 | | - assert.match( | 75 | | - child.stderr.toString(), | 76 | | - /Single executable application is an experimental feature/); | 77 | 81 |
| 78 | 82 | assert(existsSync(seaPrepBlob)); | 79 | 83 |
| 80 | 84 | copyFileSync(process.execPath, outputFile); | 81 | 85 | injectAndCodeSign(outputFile, seaPrepBlob); | 82 | 86 |
| 83 | | - child = spawnSync(outputFile); | 84 | | - assert.strictEqual(child.stdout.toString().trim(), 'Hello from snapshot'); | 85 | | - assert.doesNotMatch( | 86 | | - child.stderr.toString(), | 87 | | - /Single executable application is an experimental feature/); | | 87 | + spawnSyncAndExitWithoutError( | | 88 | + outputFile, | | 89 | + { | | 90 | + trim: true, | | 91 | + stdout: 'Hello from snapshot', | | 92 | + stderr(output) { | | 93 | + assert.doesNotMatch( | | 94 | + output, | | 95 | + /Single executable application is an experimental feature/); | | 96 | + } | | 97 | + } | | 98 | + ); | 88 | 99 | } |
|