@@ -55,7 +55,7 @@ type Config = {
5555 /**
5656 * Mapping from query filename to expected results csv file
5757 */
58- expectedResults : { [ id : string ] : string } ;
58+ expectedResults : { [ id : string ] : string | false } ;
5959} ;
6060
6161function isConfig ( config : any ) : config is Config {
@@ -74,7 +74,7 @@ function isConfig(config: any): config is Config {
7474 throw new Error ( 'Configuration property locationPaths must have the placeholder "{line-start}"' ) ;
7575 }
7676 for ( const k of Object . keys ( config . expectedResults ) ) {
77- if ( typeof config . expectedResults [ k ] !== 'string' ) {
77+ if ( typeof config . expectedResults [ k ] !== 'string' && config . expectedResults [ k ] !== false ) {
7878 throw new Error ( `Confiuration property "expectedResults" -> "${ k } " must be a string` ) ;
7979 }
8080 }
@@ -319,8 +319,13 @@ function isConfig(config: any): config is Config {
319319 console . log ( result . stdout ) ;
320320 const csvOutput = csvPath ( query ) ;
321321 await execFile ( 'codeql' , [ 'bqrs' , 'decode' , '--entities=url,string' , bqrsOutput , '--format=csv' , `--output=${ csvOutput } ` ] ) ;
322- const expectedCSV = path . join ( CONFIG_PATH , config . expectedResults [ query ] ) ;
323- results . set ( query , await checkResults ( expectedCSV , csvOutput ) ) ;
322+ const relativeExpectedCSV = config . expectedResults [ query ] ;
323+ if ( relativeExpectedCSV ) {
324+ const expectedCSV = path . join ( CONFIG_PATH , relativeExpectedCSV ) ;
325+ results . set ( query , await checkResults ( expectedCSV , csvOutput ) ) ;
326+ } else {
327+ results . set ( query , { status : 'undefined' } ) ;
328+ }
324329 }
325330
326331 for ( const entry of results . entries ( ) ) {
@@ -330,18 +335,22 @@ function isConfig(config: any): config is Config {
330335 if ( r . status === 'correct' ) {
331336 comment += ` (${ pluralize ( r . count , 'result' ) } )` ;
332337 } else {
333- if ( r . results ) {
334- comment += ` (${ pluralize ( r . results . actualCount , 'result' ) } ):\n\n` ;
335- comment += r . explanation ;
336- comment += `\nExpected query to produce ${ r . results . expectedCount } results` ;
337- comment += formatResults ( config . locationPaths , r . results . missingResults , 'Missing results' ) ;
338- comment += formatResults ( config . locationPaths , r . results . unexpectedResults , 'Unexpected results' ) ;
339- comment += formatResults ( config . locationPaths , r . results . extraResults , 'Results selected too many times' ) ;
338+ if ( r . status === 'incorrect' ) {
339+ if ( r . results ) {
340+ comment += ` (${ pluralize ( r . results . actualCount , 'result' ) } ):\n\n` ;
341+ comment += r . explanation ;
342+ comment += `\nExpected query to produce ${ r . results . expectedCount } results` ;
343+ comment += formatResults ( config . locationPaths , r . results . missingResults , 'Missing results' ) ;
344+ comment += formatResults ( config . locationPaths , r . results . unexpectedResults , 'Unexpected results' ) ;
345+ comment += formatResults ( config . locationPaths , r . results . extraResults , 'Results selected too many times' ) ;
346+ } else {
347+ comment += r . explanation ;
348+ }
349+ core . setFailed ( `Incorrect results for ${ query } ` ) ;
340350 } else {
341- comment += r . explanation ;
351+ console . log ( `No CSV defined for ${ query } :` ) ;
342352 }
343353 // Print CSV in console
344- core . setFailed ( `Incorrect results for ${ query } ` ) ;
345354 core . startGroup ( 'Actual Results CSV:' ) ;
346355 console . log ( ( await ( readFile ( csvPath ( query ) ) ) ) . toString ( ) ) ;
347356 core . endGroup ( ) ;
0 commit comments