@@ -17,33 +17,41 @@ function loadResults() {
1717 const engines = [ ] ;
1818 /** @type {Map<TestPath, Record<EngineKey, { sloppy?: Result; strict?: Result; }>> } */
1919 const testResults = new Map ( ) ;
20+ const errors = [ ] ;
2021
2122 if ( ! fs . existsSync ( ARTIFACTS_DIR ) ) {
22- return { engines, testResults } ;
23+ errors . push ( `CI job artifacts path "${ ARTIFACTS_DIR } " not found` ) ;
24+ return { engines, testResults, errors } ;
2325 }
2426
2527 const files = fs . readdirSync ( ARTIFACTS_DIR ) . filter (
2628 f => f . startsWith ( 'results-' ) && f . endsWith ( '.json' )
2729 ) ;
2830
31+ if ( files . length === 0 ) {
32+ errors . push ( `No engine test results found in "${ ARTIFACTS_DIR } "` ) ;
33+ return { engines, testResults, errors } ;
34+ }
35+
2936 for ( const file of files ) {
3037 const engineKey = file . slice ( 'results-' . length , - '.json' . length ) ;
31- engines . push ( engineKey ) ;
3238
3339 const filePath = path . join ( ARTIFACTS_DIR , file ) ;
3440 let data ;
3541 try {
3642 data = JSON . parse ( fs . readFileSync ( filePath , 'utf8' ) ) ;
3743 } catch ( err ) {
38- console . warn ( ` Failed to parse ${ file } : ${ err . message } `) ;
44+ errors . push ( `** ${ engineKey } **: Failed to parse ${ file } : ${ err . message } `) ;
3945 continue ;
4046 }
4147
4248 if ( ! Array . isArray ( data ) ) {
43- console . warn ( ` Unexpected format in ${ file } : expected JSON array`) ;
49+ errors . push ( `** ${ engineKey } **: Unexpected format in ${ file } , expected array`) ;
4450 continue ;
4551 }
4652
53+ engines . push ( engineKey ) ;
54+
4755 for ( const test of data ) {
4856 const testPath = test . relative || test . file ;
4957 if ( ! testPath ) {
@@ -71,12 +79,13 @@ function loadResults() {
7179 }
7280
7381 const orderedEngines = engines . sort ( ) ;
74- return { orderedEngines, testResults } ;
82+ return { orderedEngines, testResults, errors } ;
7583}
7684
77- function buildCommentBody ( { orderedEngines, testResults } ) {
85+ function buildCommentBody ( { orderedEngines, testResults, errors } ) {
86+ const errorList = errors . length ? "\n\nErrors encountered:" + errors . map ( s => `\n- ${ s } ` ) . join ( "" ) : "" ;
7887 if ( orderedEngines . length === 0 ) {
79- return ' No engine results were produced.' ;
88+ return ` No engine results were produced.${ errorList } ` ;
8089 }
8190
8291 const sortedTests = Array . from ( testResults . keys ( ) ) . sort ( ) ;
@@ -86,7 +95,7 @@ function buildCommentBody({ orderedEngines, testResults }) {
8695 `were run on ${ orderedEngines . length } ${ orderedEngines . length === 1 ? "engine" : "engines" } .` ;
8796 const link = WORKFLOW_RUN_URL ? `\n\n[View workflow run](${ WORKFLOW_RUN_URL } )` : '' ;
8897
89- return `${ summary } ${ link } \n\n${ table } ` ;
98+ return `${ summary } ${ link } ${ errorList } \n\n${ table } ` ;
9099}
91100
92101function buildMarkdownTable ( tests , engines , testResults ) {
0 commit comments