| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 728ebf6 commit c70c74a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const common = require('../common'); | ||
| 3 | + require('../common'); | ||
| 4 | 4 | const assert = require('assert'); | |
| 5 | - const { spawn } = require('child_process'); | ||
| 5 | + const { spawnSyncAndExit } = require('../common/child_process'); | ||
| 6 | 6 | const fixtures = require('../common/fixtures'); | |
| 7 | 7 | ||
| 8 | 8 | const node = process.execPath; | |
@@ -17,25 +17,18 @@ const syntaxErrorRE = /^SyntaxError: \b/m; | |||
| 17 | 17 | const preloadFile = fixtures.path('no-wrapper.js'); | |
| 18 | 18 | const file = fixtures.path('syntax', 'illegal_if_not_wrapped.js'); | |
| 19 | 19 | const args = [requireFlag, preloadFile, checkFlag, file]; | |
| 20 | - const cp = spawn(node, args); | ||
| 21 | - | ||
| 22 | - // No stdout should be produced | ||
| 23 | - cp.stdout.on('data', common.mustNotCall('stdout data event')); | ||
| 24 | - | ||
| 25 | - const stderrBuffer = []; | ||
| 26 | - cp.stderr.on('data', (chunk) => stderrBuffer.push(chunk)); | ||
| 27 | - | ||
| 28 | - cp.on('exit', common.mustCall((code, signal) => { | ||
| 29 | - assert.strictEqual(code, 1); | ||
| 30 | - assert.strictEqual(signal, null); | ||
| 31 | - | ||
| 32 | - const stderr = Buffer.concat(stderrBuffer).toString('utf-8'); | ||
| 33 | - // stderr should have a syntax error message | ||
| 34 | - assert.match(stderr, syntaxErrorRE); | ||
| 35 | - | ||
| 36 | - // stderr should include the filename | ||
| 37 | - assert(stderr.startsWith(file), `${stderr} starts with ${file}`); | ||
| 38 | - })); | ||
| 39 | - | ||
| 20 | + spawnSyncAndExit(node, args, { | ||
| 21 | + status: 1, | ||
| 22 | + signal: null, | ||
| 23 | + trim: true, | ||
| 24 | + stdout: '', | ||
| 25 | + stderr(output) { | ||
| 26 | + // stderr should have a syntax error message | ||
| 27 | + assert.match(output, syntaxErrorRE); | ||
| 28 | + | ||
| 29 | + // stderr should include the filename | ||
| 30 | + assert(output.startsWith(file), `${output} starts with ${file}`); | ||
| 31 | + } | ||
| 32 | + }); | ||
| 40 | 33 | }); | |
| 41 | 34 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments