-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: prefer async/await in https imports
- Loading branch information
1 parent
b39dabe
commit b3ef5cb
Showing
3 changed files
with
127 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
import * as common from '../common/index.mjs'; | ||
import assert from 'assert'; | ||
import { spawn } from 'child_process'; | ||
|
||
if (process.argv[2] !== 'child') { | ||
// Expected error not emitted. | ||
{ | ||
const child = spawn( | ||
process.execPath, [import.meta.url, 'child', 0], { encoding: 'utf8' } | ||
); | ||
child.on('exit', common.mustCall((status) => { | ||
assert.notStrictEqual(status, 0); | ||
})); | ||
} | ||
|
||
// Expected error emitted. | ||
{ | ||
const child = spawn( | ||
process.execPath, [import.meta.url, 'child', 1], { encoding: 'utf8' } | ||
); | ||
child.on('exit', common.mustCall((status) => { | ||
assert.strictEqual(status, 0); | ||
})); | ||
} | ||
|
||
// Expected error emitted too many times. | ||
{ | ||
const child = spawn( | ||
process.execPath, [import.meta.url, 'child', 2], { encoding: 'utf8' } | ||
); | ||
child.stderr.setEncoding('utf8'); | ||
|
||
const stderr = await child.stderr.reduce((stderr, data) => { | ||
return stderr + data; | ||
}, ''); | ||
const status = await once(child, 'exit') | ||
assert.notStrictEqual(status, 0); | ||
assert.match(stderr, /Unexpected extra warning received/); | ||
} | ||
} else { | ||
const iterations = +process.argv[3]; | ||
common.expectWarning('fhqwhgads', 'fhqwhgads', 'fhqwhgads'); | ||
for (let i = 0; i < iterations; i++) { | ||
process.emitWarning('fhqwhgads', 'fhqwhgads', 'fhqwhgads'); | ||
} | ||
} |