@@ -1065,29 +1065,43 @@ describe('registerCLITool handler behavior', () => {
10651065 registerCLITool ( mockServer , definition ) ;
10661066
10671067 const handler = ( mockServer . registerTool as ReturnType < typeof vi . fn > ) . mock . calls [ 0 ] [ 2 ] ;
1068+ const originalQueryLogDir = process . env . CODEQL_QUERY_LOG_DIR ;
1069+ const queryLogDir = createTestTempDir ( 'codeql-query-compile-dump-dil-logs' ) ;
10681070
1069- executeCodeQLCommand . mockResolvedValueOnce ( {
1070- stdout : 'DIL output here' ,
1071- stderr : '' ,
1072- success : true
1073- } ) ;
1071+ process . env . CODEQL_QUERY_LOG_DIR = queryLogDir ;
10741072
1075- await handler ( {
1076- query : '/path/to/query.ql' ,
1077- additionalArgs : [ '--threads=4' , '--dump-dil' , '--warnings=show' ]
1078- } ) ;
1073+ try {
1074+ executeCodeQLCommand . mockResolvedValueOnce ( {
1075+ stdout : 'DIL output here' ,
1076+ stderr : '' ,
1077+ success : true
1078+ } ) ;
10791079
1080- const call = executeCodeQLCommand . mock . calls [ 0 ] ;
1081- const options = call [ 1 ] as Record < string , unknown > ;
1082- const positionalArgs = call [ 2 ] as string [ ] ;
1080+ await handler ( {
1081+ query : '/path/to/query.ql' ,
1082+ additionalArgs : [ '--threads=4' , '--dump-dil' , '--warnings=show' ]
1083+ } ) ;
10831084
1084- // dump-dil should be normalized into options
1085- expect ( options [ 'dump-dil' ] ) . toBe ( true ) ;
1085+ const call = executeCodeQLCommand . mock . calls [ 0 ] ;
1086+ const options = call [ 1 ] as Record < string , unknown > ;
1087+ const positionalArgs = call [ 2 ] as string [ ] ;
10861088
1087- // --dump-dil should be filtered, but other args preserved
1088- expect ( positionalArgs ) . not . toContain ( '--dump-dil' ) ;
1089- expect ( positionalArgs ) . toContain ( '--threads=4' ) ;
1090- expect ( positionalArgs ) . toContain ( '--warnings=show' ) ;
1089+ // dump-dil should be normalized into options
1090+ expect ( options [ 'dump-dil' ] ) . toBe ( true ) ;
1091+
1092+ // --dump-dil should be filtered, but other args preserved
1093+ expect ( positionalArgs ) . not . toContain ( '--dump-dil' ) ;
1094+ expect ( positionalArgs ) . toContain ( '--threads=4' ) ;
1095+ expect ( positionalArgs ) . toContain ( '--warnings=show' ) ;
1096+ } finally {
1097+ if ( originalQueryLogDir === undefined ) {
1098+ delete process . env . CODEQL_QUERY_LOG_DIR ;
1099+ } else {
1100+ process . env . CODEQL_QUERY_LOG_DIR = originalQueryLogDir ;
1101+ }
1102+
1103+ rmSync ( queryLogDir , { force : true , recursive : true } ) ;
1104+ }
10911105 } ) ;
10921106
10931107 it ( 'should pass format to CLI for codeql_bqrs_interpret' , async ( ) => {
0 commit comments