@@ -55,7 +55,7 @@ type Config = {
55
55
/**
56
56
* Mapping from query filename to expected results csv file
57
57
*/
58
- expectedResults : { [ id : string ] : string } ;
58
+ expectedResults : { [ id : string ] : string | false } ;
59
59
} ;
60
60
61
61
function isConfig ( config : any ) : config is Config {
@@ -74,7 +74,7 @@ function isConfig(config: any): config is Config {
74
74
throw new Error ( 'Configuration property locationPaths must have the placeholder "{line-start}"' ) ;
75
75
}
76
76
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 ) {
78
78
throw new Error ( `Confiuration property "expectedResults" -> "${ k } " must be a string` ) ;
79
79
}
80
80
}
@@ -319,8 +319,13 @@ function isConfig(config: any): config is Config {
319
319
console . log ( result . stdout ) ;
320
320
const csvOutput = csvPath ( query ) ;
321
321
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
+ }
324
329
}
325
330
326
331
for ( const entry of results . entries ( ) ) {
@@ -330,18 +335,22 @@ function isConfig(config: any): config is Config {
330
335
if ( r . status === 'correct' ) {
331
336
comment += ` (${ pluralize ( r . count , 'result' ) } )` ;
332
337
} 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 } ` ) ;
340
350
} else {
341
- comment += r . explanation ;
351
+ console . log ( `No CSV defined for ${ query } :` ) ;
342
352
}
343
353
// Print CSV in console
344
- core . setFailed ( `Incorrect results for ${ query } ` ) ;
345
354
core . startGroup ( 'Actual Results CSV:' ) ;
346
355
console . log ( ( await ( readFile ( csvPath ( query ) ) ) ) . toString ( ) ) ;
347
356
core . endGroup ( ) ;
0 commit comments