@@ -101,9 +101,10 @@ describe("Variant Analysis Manager", () => {
101101 } ) ;
102102
103103 it ( "should run a variant analysis that is part of a qlpack" , async ( ) => {
104- const filePath = getFile ( "data-remote-qlpack/in-pack.ql" ) ;
104+ const filePath = getFileOrDir ( "data-remote-qlpack/in-pack.ql" ) ;
105105 const qlPackDetails : QlPackDetails = {
106106 queryFile : filePath ,
107+ qlPackRootPath : join ( baseDir , "data-remote-qlpack" ) ,
107108 } ;
108109
109110 await variantAnalysisManager . runVariantAnalysis (
@@ -125,9 +126,10 @@ describe("Variant Analysis Manager", () => {
125126 } ) ;
126127
127128 it ( "should run a remote query that is not part of a qlpack" , async ( ) => {
128- const filePath = getFile ( "data-remote-no-qlpack/in-pack.ql" ) ;
129+ const filePath = getFileOrDir ( "data-remote-no-qlpack/in-pack.ql" ) ;
129130 const qlPackDetails : QlPackDetails = {
130131 queryFile : filePath ,
132+ qlPackRootPath : join ( baseDir , "data-remote-no-qlpack" ) ,
131133 } ;
132134
133135 await variantAnalysisManager . runVariantAnalysis (
@@ -149,11 +151,12 @@ describe("Variant Analysis Manager", () => {
149151 } ) ;
150152
151153 it ( "should run a remote query that is nested inside a qlpack" , async ( ) => {
152- const filePath = getFile (
154+ const filePath = getFileOrDir (
153155 "data-remote-qlpack-nested/subfolder/in-pack.ql" ,
154156 ) ;
155157 const qlPackDetails : QlPackDetails = {
156158 queryFile : filePath ,
159+ qlPackRootPath : join ( baseDir , "data-remote-qlpack-nested" ) ,
157160 } ;
158161
159162 await variantAnalysisManager . runVariantAnalysis (
@@ -175,9 +178,10 @@ describe("Variant Analysis Manager", () => {
175178 } ) ;
176179
177180 it ( "should cancel a run before uploading" , async ( ) => {
178- const filePath = getFile ( "data-remote-no-qlpack/in-pack.ql" ) ;
181+ const filePath = getFileOrDir ( "data-remote-no-qlpack/in-pack.ql" ) ;
179182 const qlPackDetails : QlPackDetails = {
180183 queryFile : filePath ,
184+ qlPackRootPath : join ( baseDir , "data-remote-no-qlpack" ) ,
181185 } ;
182186
183187 const promise = variantAnalysisManager . runVariantAnalysis (
@@ -218,6 +222,7 @@ describe("Variant Analysis Manager", () => {
218222 it ( "should run a remote query that is part of a qlpack" , async ( ) => {
219223 await doVariantAnalysisTest ( {
220224 queryPath : "data-remote-qlpack/in-pack.ql" ,
225+ qlPackRootPath : "data-remote-qlpack" ,
221226 expectedPackName : "github/remote-query-pack" ,
222227 filesThatExist : [ "in-pack.ql" , "lib.qll" ] ,
223228 filesThatDoNotExist : [ ] ,
@@ -228,6 +233,7 @@ describe("Variant Analysis Manager", () => {
228233 it ( "should run a remote query that is not part of a qlpack" , async ( ) => {
229234 await doVariantAnalysisTest ( {
230235 queryPath : "data-remote-no-qlpack/in-pack.ql" ,
236+ qlPackRootPath : "data-remote-no-qlpack" ,
231237 expectedPackName : "codeql-remote/query" ,
232238 filesThatExist : [ "in-pack.ql" ] ,
233239 filesThatDoNotExist : [ "lib.qll" , "not-in-pack.ql" ] ,
@@ -238,6 +244,7 @@ describe("Variant Analysis Manager", () => {
238244 it ( "should run a remote query that is nested inside a qlpack" , async ( ) => {
239245 await doVariantAnalysisTest ( {
240246 queryPath : "data-remote-qlpack-nested/subfolder/in-pack.ql" ,
247+ qlPackRootPath : "data-remote-qlpack-nested" ,
241248 expectedPackName : "github/remote-query-pack" ,
242249 filesThatExist : [ "subfolder/in-pack.ql" , "otherfolder/lib.qll" ] ,
243250 filesThatDoNotExist : [ "subfolder/not-in-pack.ql" ] ,
@@ -255,6 +262,7 @@ describe("Variant Analysis Manager", () => {
255262 await cli . setUseExtensionPacks ( true ) ;
256263 await doVariantAnalysisTest ( {
257264 queryPath : "data-remote-qlpack-nested/subfolder/in-pack.ql" ,
265+ qlPackRootPath : "data-remote-qlpack-nested" ,
258266 expectedPackName : "github/remote-query-pack" ,
259267 filesThatExist : [
260268 "subfolder/in-pack.ql" ,
@@ -299,12 +307,11 @@ describe("Variant Analysis Manager", () => {
299307 ? [ "Telemetry/ExtractorInformation.ql" ]
300308 : [ ] ;
301309
310+ const qlPackRootPath = join ( process . env . TEST_CODEQL_PATH , "java/ql/src" ) ;
311+ const queryPath = join ( qlPackRootPath , queryToRun ) ;
302312 await doVariantAnalysisTest ( {
303- queryPath : join (
304- process . env . TEST_CODEQL_PATH ,
305- "java/ql/src" ,
306- queryToRun ,
307- ) ,
313+ queryPath,
314+ qlPackRootPath,
308315 expectedPackName : "codeql/java-queries" ,
309316 filesThatExist : [ queryToRun , ...extraQueries ] ,
310317 filesThatDoNotExist : [ ] ,
@@ -317,6 +324,7 @@ describe("Variant Analysis Manager", () => {
317324
318325 async function doVariantAnalysisTest ( {
319326 queryPath,
327+ qlPackRootPath,
320328 expectedPackName,
321329 filesThatExist,
322330 qlxFilesThatExist,
@@ -328,16 +336,18 @@ describe("Variant Analysis Manager", () => {
328336 checkVersion = true ,
329337 } : {
330338 queryPath : string ;
339+ qlPackRootPath : string ;
331340 expectedPackName : string ;
332341 filesThatExist : string [ ] ;
333342 qlxFilesThatExist : string [ ] ;
334343 filesThatDoNotExist : string [ ] ;
335344 dependenciesToCheck ?: string [ ] ;
336345 checkVersion ?: boolean ;
337346 } ) {
338- const filePath = getFile ( queryPath ) ;
347+ const filePath = getFileOrDir ( queryPath ) ;
339348 const qlPackDetails : QlPackDetails = {
340349 queryFile : filePath ,
350+ qlPackRootPath : getFileOrDir ( qlPackRootPath ) ,
341351 } ;
342352
343353 await variantAnalysisManager . runVariantAnalysis (
@@ -416,11 +426,11 @@ describe("Variant Analysis Manager", () => {
416426 ) ;
417427 }
418428
419- function getFile ( file : string ) : string {
420- if ( isAbsolute ( file ) ) {
421- return file ;
429+ function getFileOrDir ( path : string ) : string {
430+ if ( isAbsolute ( path ) ) {
431+ return path ;
422432 } else {
423- return join ( baseDir , file ) ;
433+ return join ( baseDir , path ) ;
424434 }
425435 }
426436 } ) ;
0 commit comments