| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,11 +70,15 @@ gathering more information about test failures coming from child processes. | |||
| 70 | 70 | * `stderr` [\<string>][<string>] The output from the child process to stderr. | |
| 71 | 71 | * `stdout` [\<string>][<string>] The output from the child process to stdout. | |
| 72 | 72 | ||
| 73 | - ### `spawnSyncAndExitWithoutError(command[, args][, spawnOptions], expectations)` | ||
| 73 | + ### `spawnSyncAndExitWithoutError(command[, args][, spawnOptions])` | ||
| 74 | 74 | ||
| 75 | 75 | Similar to `expectSyncExit()` with the `status` expected to be 0 and | |
| 76 | - `signal` expected to be `null`. Any other optional options are passed | ||
| 77 | - into `expectSyncExit()`. | ||
| 76 | + `signal` expected to be `null`. | ||
| 77 | + | ||
| 78 | + ### `spawnSyncAndAssert(command[, args][, spawnOptions], expectations)` | ||
| 79 | + | ||
| 80 | + Similar to `spawnSyncAndExitWithoutError()`, but with an additional | ||
| 81 | + `expectations` parameter. | ||
| 78 | 82 | ||
| 79 | 83 | ## Common Module API | |
| 80 | 84 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,9 +119,15 @@ function spawnSyncAndExit(...args) { | |||
| 119 | 119 | } | |
| 120 | 120 | ||
| 121 | 121 | function spawnSyncAndExitWithoutError(...args) { | |
| 122 | - const spawnArgs = args.slice(0, args.length); | ||
| 123 | - const expectations = args[args.length - 1]; | ||
| 124 | - const child = spawnSync(...spawnArgs); | ||
| 122 | + return expectSyncExit(spawnSync(...args), { | ||
| 123 | + status: 0, | ||
| 124 | + signal: null, | ||
| 125 | + }); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + function spawnSyncAndAssert(...args) { | ||
| 129 | + const expectations = args.pop(); | ||
| 130 | + const child = spawnSync(...args); | ||
| 125 | 131 | return expectSyncExit(child, { | |
| 126 | 132 | status: 0, | |
| 127 | 133 | signal: null, | |
@@ -134,6 +140,7 @@ module.exports = { | |||
| 134 | 140 | logAfterTime, | |
| 135 | 141 | kExpiringChildRunTime, | |
| 136 | 142 | kExpiringParentTimer, | |
| 143 | + spawnSyncAndAssert, | ||
| 137 | 144 | spawnSyncAndExit, | |
| 138 | 145 | spawnSyncAndExitWithoutError, | |
| 139 | 146 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,8 +92,8 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow | |||
| 92 | 92 | ||
| 93 | 93 | if (process.platform === 'darwin') { | |
| 94 | 94 | try { | |
| 95 | - spawnSyncAndExitWithoutError('codesign', [ '--sign', '-', targetExecutable ], {}); | ||
| 96 | - spawnSyncAndExitWithoutError('codesign', [ '--verify', targetExecutable ], {}); | ||
| 95 | + spawnSyncAndExitWithoutError('codesign', [ '--sign', '-', targetExecutable ]); | ||
| 96 | + spawnSyncAndExitWithoutError('codesign', [ '--verify', targetExecutable ]); | ||
| 97 | 97 | } catch (e) { | |
| 98 | 98 | const message = `Cannot sign ${targetExecutable}: ${inspect(e)}`; | |
| 99 | 99 | if (verifyWorkflow) { | |
@@ -104,7 +104,7 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow | |||
| 104 | 104 | console.log(`Signed ${targetExecutable}`); | |
| 105 | 105 | } else if (process.platform === 'win32') { | |
| 106 | 106 | try { | |
| 107 | - spawnSyncAndExitWithoutError('where', [ 'signtool' ], {}); | ||
| 107 | + spawnSyncAndExitWithoutError('where', [ 'signtool' ]); | ||
| 108 | 108 | } catch (e) { | |
| 109 | 109 | const message = `Cannot find signtool: ${inspect(e)}`; | |
| 110 | 110 | if (verifyWorkflow) { | |
@@ -114,8 +114,8 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow | |||
| 114 | 114 | } | |
| 115 | 115 | let stderr; | |
| 116 | 116 | try { | |
| 117 | - ({ stderr } = spawnSyncAndExitWithoutError('signtool', [ 'sign', '/fd', 'SHA256', targetExecutable ], {})); | ||
| 118 | - spawnSyncAndExitWithoutError('signtool', 'verify', '/pa', 'SHA256', targetExecutable, {}); | ||
| 117 | + ({ stderr } = spawnSyncAndExitWithoutError('signtool', [ 'sign', '/fd', 'SHA256', targetExecutable ])); | ||
| 118 | + spawnSyncAndExitWithoutError('signtool', ['verify', '/pa', 'SHA256', targetExecutable]); | ||
| 119 | 119 | } catch (e) { | |
| 120 | 120 | const message = `Cannot sign ${targetExecutable}: ${inspect(e)}\n${stderr}`; | |
| 121 | 121 | if (verifyWorkflow) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | // Test version set to preview1 | |
| 2 | 2 | 'use strict'; | |
| 3 | 3 | ||
| 4 | - const { spawnSyncAndExitWithoutError } = require('./child_process'); | ||
| 4 | + const { spawnSyncAndAssert } = require('./child_process'); | ||
| 5 | 5 | const fixtures = require('./fixtures'); | |
| 6 | 6 | const childPath = fixtures.path('wasi-preview-1.js'); | |
| 7 | 7 | ||
@@ -15,7 +15,7 @@ function testWasiPreview1(args, spawnArgs = {}, expectations = {}) { | |||
| 15 | 15 | spawnArgs.env = newEnv; | |
| 16 | 16 | ||
| 17 | 17 | console.log('Testing with --turbo-fast-api-calls:', ...args); | |
| 18 | - spawnSyncAndExitWithoutError( | ||
| 18 | + spawnSyncAndAssert( | ||
| 19 | 19 | process.execPath, [ | |
| 20 | 20 | '--turbo-fast-api-calls', | |
| 21 | 21 | childPath, | |
@@ -26,7 +26,7 @@ function testWasiPreview1(args, spawnArgs = {}, expectations = {}) { | |||
| 26 | 26 | ); | |
| 27 | 27 | ||
| 28 | 28 | console.log('Testing with --no-turbo-fast-api-calls:', ...args); | |
| 29 | - spawnSyncAndExitWithoutError( | ||
| 29 | + spawnSyncAndAssert( | ||
| 30 | 30 | process.execPath, | |
| 31 | 31 | [ | |
| 32 | 32 | '--no-turbo-fast-api-calls', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ const fixtures = require('../common/fixtures'); | |||
| 4 | 4 | const tmpdir = require('../common/tmpdir'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | const { | |
| 7 | + spawnSyncAndAssert, | ||
| 7 | 8 | spawnSyncAndExit, | |
| 8 | 9 | spawnSyncAndExitWithoutError, | |
| 9 | 10 | } = require('../common/child_process'); | |
@@ -23,15 +24,15 @@ function resolveBuiltBinary(binary) { | |||
| 23 | 24 | ||
| 24 | 25 | const binary = resolveBuiltBinary('embedtest'); | |
| 25 | 26 | ||
| 26 | - spawnSyncAndExitWithoutError( | ||
| 27 | + spawnSyncAndAssert( | ||
| 27 | 28 | binary, | |
| 28 | 29 | ['console.log(42)'], | |
| 29 | 30 | { | |
| 30 | 31 | trim: true, | |
| 31 | 32 | stdout: '42', | |
| 32 | 33 | }); | |
| 33 | 34 | ||
| 34 | - spawnSyncAndExitWithoutError( | ||
| 35 | + spawnSyncAndAssert( | ||
| 35 | 36 | binary, | |
| 36 | 37 | ['console.log(embedVars.nön_ascıı)'], | |
| 37 | 38 | { | |
@@ -111,9 +112,8 @@ for (const extraSnapshotArgs of [ | |||
| 111 | 112 | spawnSyncAndExitWithoutError( | |
| 112 | 113 | binary, | |
| 113 | 114 | [ '--', ...buildSnapshotArgs ], | |
| 114 | - { cwd: tmpdir.path }, | ||
| 115 | - {}); | ||
| 116 | - spawnSyncAndExitWithoutError( | ||
| 115 | + { cwd: tmpdir.path }); | ||
| 116 | + spawnSyncAndAssert( | ||
| 117 | 117 | binary, | |
| 118 | 118 | [ '--', ...runSnapshotArgs ], | |
| 119 | 119 | { cwd: tmpdir.path }, | |
@@ -145,11 +145,9 @@ for (const extraSnapshotArgs of [ | |||
| 145 | 145 | spawnSyncAndExitWithoutError( | |
| 146 | 146 | binary, | |
| 147 | 147 | [ '--', ...buildSnapshotArgs ], | |
| 148 | - { cwd: tmpdir.path }, | ||
| 149 | - {}); | ||
| 148 | + { cwd: tmpdir.path }); | ||
| 150 | 149 | spawnSyncAndExitWithoutError( | |
| 151 | 150 | binary, | |
| 152 | 151 | [ '--', ...runEmbeddedArgs ], | |
| 153 | - { cwd: tmpdir.path }, | ||
| 154 | - {}); | ||
| 152 | + { cwd: tmpdir.path }); | ||
| 155 | 153 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,5 @@ if (process.argv[2] !== 'child') { | |||
| 26 | 26 | // enabled. | |
| 27 | 27 | spawnSyncAndExitWithoutError( | |
| 28 | 28 | process.execPath, | |
| 29 | - ['--enable-source-maps', __filename, 'child'], | ||
| 30 | - {}); | ||
| 29 | + ['--enable-source-maps', __filename, 'child']); | ||
| 31 | 30 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ require('../common'); | |||
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | const tmpdir = require('../common/tmpdir'); | |
| 8 | 8 | const fixtures = require('../common/fixtures'); | |
| 9 | - const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 9 | + const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 10 | 10 | const fs = require('fs'); | |
| 11 | 11 | ||
| 12 | 12 | const v8 = require('v8'); | |
@@ -41,7 +41,7 @@ const entry = fixtures.path('snapshot', 'v8-startup-snapshot-api.js'); | |||
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | { | |
| 44 | - spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 44 | + spawnSyncAndAssert(process.execPath, [ | ||
| 45 | 45 | '--snapshot-blob', | |
| 46 | 46 | blobPath, | |
| 47 | 47 | 'book1', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,8 +8,9 @@ const assert = require('assert'); | |||
| 8 | 8 | const tmpdir = require('../common/tmpdir'); | |
| 9 | 9 | const fixtures = require('../common/fixtures'); | |
| 10 | 10 | const { | |
| 11 | - spawnSyncAndExitWithoutError, | ||
| 11 | + spawnSyncAndAssert, | ||
| 12 | 12 | spawnSyncAndExit, | |
| 13 | + spawnSyncAndExitWithoutError, | ||
| 13 | 14 | } = require('../common/child_process'); | |
| 14 | 15 | const fs = require('fs'); | |
| 15 | 16 | ||
@@ -65,7 +66,7 @@ const blobPath = tmpdir.resolve('my-snapshot.blob'); | |||
| 65 | 66 | ||
| 66 | 67 | { | |
| 67 | 68 | // Check --help. | |
| 68 | - spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 69 | + spawnSyncAndAssert(process.execPath, [ | ||
| 69 | 70 | '--snapshot-blob', | |
| 70 | 71 | blobPath, | |
| 71 | 72 | '--help', | |
@@ -78,7 +79,7 @@ const blobPath = tmpdir.resolve('my-snapshot.blob'); | |||
| 78 | 79 | ||
| 79 | 80 | { | |
| 80 | 81 | // Check -c. | |
| 81 | - spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 82 | + spawnSyncAndAssert(process.execPath, [ | ||
| 82 | 83 | '--snapshot-blob', | |
| 83 | 84 | blobPath, | |
| 84 | 85 | '-c', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | // restoring state from a snapshot | |
| 5 | 5 | ||
| 6 | 6 | require('../common'); | |
| 7 | - const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 7 | + const { spawnSyncAndAssert } = require('../common/child_process'); | ||
| 8 | 8 | const tmpdir = require('../common/tmpdir'); | |
| 9 | 9 | const fixtures = require('../common/fixtures'); | |
| 10 | 10 | const assert = require('assert'); | |
@@ -20,7 +20,7 @@ const expected = [ | |||
| 20 | 20 | ||
| 21 | 21 | { | |
| 22 | 22 | // Create the snapshot. | |
| 23 | - spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 23 | + spawnSyncAndAssert(process.execPath, [ | ||
| 24 | 24 | '--snapshot-blob', | |
| 25 | 25 | blobPath, | |
| 26 | 26 | '--build-snapshot', | |
@@ -37,7 +37,7 @@ const expected = [ | |||
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | 39 | { | |
| 40 | - spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 40 | + spawnSyncAndAssert(process.execPath, [ | ||
| 41 | 41 | '--snapshot-blob', | |
| 42 | 42 | blobPath, | |
| 43 | 43 | file, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,8 +5,9 @@ | |||
| 5 | 5 | require('../common'); | |
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | const { | |
| 8 | - spawnSyncAndExitWithoutError, | ||
| 8 | + spawnSyncAndAssert, | ||
| 9 | 9 | spawnSyncAndExit, | |
| 10 | + spawnSyncAndExitWithoutError, | ||
| 10 | 11 | } = require('../common/child_process'); | |
| 11 | 12 | const tmpdir = require('../common/tmpdir'); | |
| 12 | 13 | const fixtures = require('../common/fixtures'); | |
@@ -84,7 +85,7 @@ let sizeWithCache; | |||
| 84 | 85 | configPath, | |
| 85 | 86 | ], { | |
| 86 | 87 | cwd: tmpdir.path | |
| 87 | - }, {}); | ||
| 88 | + }); | ||
| 88 | 89 | const stats = fs.statSync(blobPath); | |
| 89 | 90 | assert(stats.isFile()); | |
| 90 | 91 | sizeWithCache = stats.size; | |
@@ -115,14 +116,14 @@ let sizeWithoutCache; | |||
| 115 | 116 | NODE_DEBUG_NATIVE: 'CODE_CACHE' | |
| 116 | 117 | }, | |
| 117 | 118 | cwd: tmpdir.path | |
| 118 | - }, {}); | ||
| 119 | + }); | ||
| 119 | 120 | const stats = fs.statSync(blobPath); | |
| 120 | 121 | assert(stats.isFile()); | |
| 121 | 122 | sizeWithoutCache = stats.size; | |
| 122 | 123 | assert(sizeWithoutCache < sizeWithCache, | |
| 123 | 124 | `sizeWithoutCache = ${sizeWithoutCache} >= sizeWithCache ${sizeWithCache}`); | |
| 124 | 125 | // Check the snapshot. | |
| 125 | - spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 126 | + spawnSyncAndAssert(process.execPath, [ | ||
| 126 | 127 | '--snapshot-blob', | |
| 127 | 128 | blobPath, | |
| 128 | 129 | checkFile, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments