| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c136d59 commit 75c565b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -549,7 +549,11 @@ function _expectWarning(name, expected, code) { | |||
| 549 | 549 | expected.forEach(([_, code]) => assert(code, expected)); | |
| 550 | 550 | } | |
| 551 | 551 | return mustCall((warning) => { | |
| 552 | - const [ message, code ] = expected.shift(); | ||
| 552 | + const expectedProperties = expected.shift(); | ||
| 553 | + if (!expectedProperties) { | ||
| 554 | + assert.fail(`Unexpected extra warning received: ${warning}`); | ||
| 555 | + } | ||
| 556 | + const [ message, code ] = expectedProperties; | ||
| 553 | 557 | assert.strictEqual(warning.name, name); | |
| 554 | 558 | if (typeof message === 'string') { | |
| 555 | 559 | assert.strictEqual(warning.message, message); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,50 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { spawn } = require('child_process'); | ||
| 6 | + | ||
| 7 | + if (process.argv[2] !== 'child') { | ||
| 8 | + // Expected error not emitted. | ||
| 9 | + { | ||
| 10 | + const child = spawn( | ||
| 11 | + process.execPath, [__filename, 'child', 0], { encoding: 'utf8' } | ||
| 12 | + ); | ||
| 13 | + child.on('exit', common.mustCall((status) => { | ||
| 14 | + assert.notStrictEqual(status, 0); | ||
| 15 | + })); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + // Expected error emitted. | ||
| 19 | + { | ||
| 20 | + const child = spawn( | ||
| 21 | + process.execPath, [__filename, 'child', 1], { encoding: 'utf8' } | ||
| 22 | + ); | ||
| 23 | + child.on('exit', common.mustCall((status) => { | ||
| 24 | + assert.strictEqual(status, 0); | ||
| 25 | + })); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + // Expected error emitted too many times. | ||
| 29 | + { | ||
| 30 | + const child = spawn( | ||
| 31 | + process.execPath, [__filename, 'child', 2], { encoding: 'utf8' } | ||
| 32 | + ); | ||
| 33 | + child.stderr.setEncoding('utf8'); | ||
| 34 | + | ||
| 35 | + let stderr = ''; | ||
| 36 | + child.stderr.on('data', (data) => { | ||
| 37 | + stderr += data; | ||
| 38 | + }); | ||
| 39 | + child.on('exit', common.mustCall((status) => { | ||
| 40 | + assert.notStrictEqual(status, 0); | ||
| 41 | + assert.match(stderr, /Unexpected extra warning received/); | ||
| 42 | + })); | ||
| 43 | + } | ||
| 44 | + } else { | ||
| 45 | + const iterations = +process.argv[3]; | ||
| 46 | + common.expectWarning('fhqwhgads', 'fhqwhgads', 'fhqwhgads'); | ||
| 47 | + for (let i = 0; i < iterations; i++) { | ||
| 48 | + process.emitWarning('fhqwhgads', 'fhqwhgads', 'fhqwhgads'); | ||
| 49 | + } | ||
| 50 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments