@@ -236,7 +236,7 @@ describe("Variant Analysis Manager", () => {
236236
237237 it ( "should run a remote query that is part of a qlpack" , async ( ) => {
238238 await doVariantAnalysisTest ( {
239- queryPath : "data-remote-qlpack/in-pack.ql" ,
239+ queryPaths : [ "data-remote-qlpack/in-pack.ql" ] ,
240240 qlPackRootPath : "data-remote-qlpack" ,
241241 qlPackFilePath : "data-remote-qlpack/qlpack.yml" ,
242242 expectedPackName : "github/remote-query-pack" ,
@@ -248,7 +248,7 @@ describe("Variant Analysis Manager", () => {
248248
249249 it ( "should run a remote query that is not part of a qlpack" , async ( ) => {
250250 await doVariantAnalysisTest ( {
251- queryPath : "data-remote-no-qlpack/in-pack.ql" ,
251+ queryPaths : [ "data-remote-no-qlpack/in-pack.ql" ] ,
252252 qlPackRootPath : "data-remote-no-qlpack" ,
253253 qlPackFilePath : undefined ,
254254 expectedPackName : "codeql-remote/query" ,
@@ -260,7 +260,7 @@ describe("Variant Analysis Manager", () => {
260260
261261 it ( "should run a remote query that is nested inside a qlpack" , async ( ) => {
262262 await doVariantAnalysisTest ( {
263- queryPath : "data-remote-qlpack-nested/subfolder/in-pack.ql" ,
263+ queryPaths : [ "data-remote-qlpack-nested/subfolder/in-pack.ql" ] ,
264264 qlPackRootPath : "data-remote-qlpack-nested" ,
265265 qlPackFilePath : "data-remote-qlpack-nested/codeql-pack.yml" ,
266266 expectedPackName : "github/remote-query-pack" ,
@@ -279,7 +279,7 @@ describe("Variant Analysis Manager", () => {
279279 }
280280 await cli . setUseExtensionPacks ( true ) ;
281281 await doVariantAnalysisTest ( {
282- queryPath : "data-remote-qlpack-nested/subfolder/in-pack.ql" ,
282+ queryPaths : [ "data-remote-qlpack-nested/subfolder/in-pack.ql" ] ,
283283 qlPackRootPath : "data-remote-qlpack-nested" ,
284284 qlPackFilePath : "data-remote-qlpack-nested/codeql-pack.yml" ,
285285 expectedPackName : "github/remote-query-pack" ,
@@ -330,7 +330,7 @@ describe("Variant Analysis Manager", () => {
330330 const queryPath = join ( qlPackRootPath , queryToRun ) ;
331331 const qlPackFilePath = join ( qlPackRootPath , "qlpack.yml" ) ;
332332 await doVariantAnalysisTest ( {
333- queryPath,
333+ queryPaths : [ queryPath ] ,
334334 qlPackRootPath,
335335 qlPackFilePath,
336336 expectedPackName : "codeql/java-queries" ,
@@ -343,8 +343,31 @@ describe("Variant Analysis Manager", () => {
343343 } ) ;
344344 } ) ;
345345
346+ it ( "should run multiple queries that are part of the same pack" , async ( ) => {
347+ if ( ! ( await cli . cliConstraints . supportsPackCreateWithMultipleQueries ( ) ) ) {
348+ console . log (
349+ `Skipping test because MRVA with multiple queries is only suppported in CLI version ${ CliVersionConstraint . CLI_VERSION_WITH_MULTI_QUERY_PACK_CREATE } or later.` ,
350+ ) ;
351+ return ;
352+ }
353+
354+ await doVariantAnalysisTest ( {
355+ queryPaths : [
356+ "data-qlpack-multiple-queries/query1.ql" ,
357+ "data-qlpack-multiple-queries/query2.ql" ,
358+ ] ,
359+ qlPackRootPath : "data-qlpack-multiple-queries" ,
360+ qlPackFilePath : "data-qlpack-multiple-queries/codeql-pack.yml" ,
361+ expectedPackName : "github/remote-query-pack" ,
362+ filesThatExist : [ "query1.ql" , "query2.ql" ] ,
363+ filesThatDoNotExist : [ ] ,
364+ qlxFilesThatExist : [ "query1.qlx" , "query2.qlx" ] ,
365+ dependenciesToCheck : [ "codeql/javascript-all" ] ,
366+ } ) ;
367+ } ) ;
368+
346369 async function doVariantAnalysisTest ( {
347- queryPath ,
370+ queryPaths ,
348371 qlPackRootPath,
349372 qlPackFilePath,
350373 expectedPackName,
@@ -357,7 +380,7 @@ describe("Variant Analysis Manager", () => {
357380 dependenciesToCheck = [ "codeql/javascript-all" ] ,
358381 checkVersion = true ,
359382 } : {
360- queryPath : string ;
383+ queryPaths : string [ ] ;
361384 qlPackRootPath : string ;
362385 qlPackFilePath : string | undefined ;
363386 expectedPackName : string ;
@@ -367,9 +390,9 @@ describe("Variant Analysis Manager", () => {
367390 dependenciesToCheck ?: string [ ] ;
368391 checkVersion ?: boolean ;
369392 } ) {
370- const filePath = getFileOrDir ( queryPath ) ;
393+ const filePaths = queryPaths . map ( getFileOrDir ) ;
371394 const qlPackDetails : QlPackDetails = {
372- queryFiles : [ filePath ] ,
395+ queryFiles : filePaths ,
373396 qlPackRootPath : getFileOrDir ( qlPackRootPath ) ,
374397 qlPackFilePath : qlPackFilePath && getFileOrDir ( qlPackFilePath ) ,
375398 language : QueryLanguage . Javascript ,
@@ -385,7 +408,7 @@ describe("Variant Analysis Manager", () => {
385408 expect ( executeCommandSpy ) . toHaveBeenCalledWith (
386409 "codeQL.monitorNewVariantAnalysis" ,
387410 expect . objectContaining ( {
388- query : expect . objectContaining ( { filePath } ) ,
411+ query : expect . objectContaining ( { filePath : filePaths [ 0 ] } ) ,
389412 } ) ,
390413 ) ;
391414
0 commit comments