88 fourthTestString ,
99 multibyteString ,
1010} from './helpers/arguments.js' ;
11- import { assertFail , assertErrorEvent } from './helpers/assert.js' ;
11+ import { assertAbortError , assertFail , assertErrorEvent } from './helpers/assert.js' ;
1212import {
1313 nodeEval ,
1414 nodePrintStdout ,
@@ -19,6 +19,7 @@ import {
1919 nodePassThrough ,
2020 nodePassThroughPrint ,
2121 nodePassThroughPrintFail ,
22+ nodeHanging ,
2223} from './helpers/commands.js' ;
2324
2425const getIterable = ( subprocess , iterableType ) => iterableType === ''
@@ -222,6 +223,21 @@ const testStreamIterateAllError = async (t, streamName) => {
222223test ( 'Handles subprocess.stdout error in subprocess[Symbol.asyncIterator]' , testStreamIterateAllError , 'stdout' ) ;
223224test ( 'Handles subprocess.stderr error in subprocess[Symbol.asyncIterator]' , testStreamIterateAllError , 'stderr' ) ;
224225
226+ const testStreamIterateSignal = async ( t , streamName ) => {
227+ const signal = AbortSignal . timeout ( 0 ) ;
228+ const subprocess = spawn ( ...nodeHanging , { signal} ) ;
229+ const error = await t . throwsAsync ( arrayFromAsync ( subprocess [ streamName ] ) ) ;
230+ assertAbortError ( t , error , signal . reason ) ;
231+ const promiseError = await t . throwsAsync ( subprocess ) ;
232+ t . is ( promiseError , error ) ;
233+ t . is ( promiseError . stdout , '' ) ;
234+ t . is ( promiseError . stderr , '' ) ;
235+ t . is ( promiseError . output , '' ) ;
236+ } ;
237+
238+ test ( 'Handles subprocess.stdout error with the "signal" option' , testStreamIterateSignal , 'stdout' ) ;
239+ test ( 'Handles subprocess.stderr error with the "signal" option' , testStreamIterateSignal , 'stderr' ) ;
240+
225241// eslint-disable-next-line max-params
226242const iterateOnOutput = async ( t , subprocess , state , cause , shouldThrow , iterableType ) => {
227243 // eslint-disable-next-line no-unreachable-loop
0 commit comments