@@ -285,30 +285,40 @@ exec "${hermesc}" "$@"
285285 ) ;
286286 const map = path . join ( outputFolder , `${ bundleName } .map` ) ;
287287 fs . writeFileSync ( map , '{}' ) ;
288- const cwd = process . cwd ( ) ;
289- const unhandled : unknown [ ] = [ ] ;
290- const onUnhandled = ( error : unknown ) => unhandled . push ( error ) ;
291- process . on ( 'unhandledRejection' , onUnhandled ) ;
292- process . chdir ( dir ) ;
293- try {
294- const result = await compileHermesByteCode ( {
295- bundleName,
296- outputFolder,
297- sourcemapOutput : map ,
298- shouldCleanSourcemap : true ,
299- baseRequest : { option : baseHbc , verify : true } ,
300- hermesCommand : wrapper ,
301- } ) ;
302- expect ( fs . existsSync ( marker ) ) . toBe ( true ) ;
303- expect ( result . outcome ) . toBe ( 'dump-failed' ) ;
304- expect ( result . base ) . toBeNull ( ) ;
305- expect ( unhandled ) . toEqual ( [ ] ) ;
306- expect ( fs . readFileSync ( map , 'utf8' ) ) . toBe ( '{}' ) ;
307- expect ( leftovers ( ) ) . toEqual ( [ ] ) ;
308- } finally {
309- process . chdir ( cwd ) ;
310- process . off ( 'unhandledRejection' , onUnhandled ) ;
311- }
288+ const child = spawnSync (
289+ process . execPath ,
290+ [
291+ path . join ( __dirname , 'fixtures/hermes-async-check.cjs' ) ,
292+ JSON . stringify ( {
293+ operation : 'compile' ,
294+ modulePath : require . resolve ( '../src/bundle-runner' ) ,
295+ cwd : dir ,
296+ options : {
297+ bundleName,
298+ outputFolder,
299+ sourcemapOutput : map ,
300+ shouldCleanSourcemap : true ,
301+ baseRequest : { option : baseHbc , verify : true } ,
302+ hermesCommand : wrapper ,
303+ } ,
304+ } ) ,
305+ ] ,
306+ { encoding : 'utf8' , timeout : 4000 } ,
307+ ) ;
308+ expect ( child . error ) . toBeUndefined ( ) ;
309+ expect ( child . signal ) . toBeNull ( ) ;
310+ expect ( child . status ) . toBe ( 0 ) ;
311+ expect ( child . stderr ) . not . toContain ( 'HERMES_ASYNC_ERROR' ) ;
312+ const line = child . stdout
313+ . split ( '\n' )
314+ . find ( ( value ) => value . startsWith ( 'HERMES_ASYNC_RESULT ' ) ) ;
315+ expect ( line ) . toBeDefined ( ) ;
316+ const result = JSON . parse ( line ! . slice ( 'HERMES_ASYNC_RESULT ' . length ) ) ;
317+ expect ( fs . existsSync ( marker ) ) . toBe ( true ) ;
318+ expect ( result . outcome ) . toBe ( 'dump-failed' ) ;
319+ expect ( result . base ) . toBeNull ( ) ;
320+ expect ( fs . readFileSync ( map , 'utf8' ) ) . toBe ( '{}' ) ;
321+ expect ( leftovers ( ) ) . toEqual ( [ ] ) ;
312322 } , 5000 ) ;
313323
314324 test ( 'a selection started ahead of time is consumed by the compile' , async ( ) => {
0 commit comments