@@ -188,8 +188,12 @@ describe("Release version ordering", () => {
188188} ) ;
189189
190190describe ( 'Launcher path' , ( ) => {
191+ const pathToCmd = `abc${ path . sep } codeql.cmd` ;
192+ const pathToExe = `abc${ path . sep } codeql.exe` ;
193+
191194 let sandbox : sinon . SinonSandbox ;
192195 let warnSpy : sinon . SinonSpy ;
196+ let errorSpy : sinon . SinonSpy ;
193197 let logSpy : sinon . SinonSpy ;
194198 let fsSpy : sinon . SinonSpy ;
195199 let platformSpy : sinon . SinonSpy ;
@@ -209,37 +213,37 @@ describe('Launcher path', () => {
209213 it ( 'should not warn with proper launcher name' , async ( ) => {
210214 launcherThatExists = 'codeql.exe' ;
211215 const result = await getExecutableFromDirectory ( 'abc' ) ;
212- expect ( fsSpy ) . to . have . been . calledWith ( `abc ${ path . sep } codeql.exe` ) ;
216+ expect ( fsSpy ) . to . have . been . calledWith ( pathToExe ) ;
213217
214218 // correct launcher has been found, so alternate one not looked for
215- expect ( fsSpy ) . not . to . have . been . calledWith ( `abc ${ path . sep } codeql.cmd` ) ;
219+ expect ( fsSpy ) . not . to . have . been . calledWith ( pathToCmd ) ;
216220
217221 // no warning message
218222 expect ( warnSpy ) . not . to . have . been . calledWith ( sinon . match . string ) ;
219223 // No log message
220224 expect ( logSpy ) . not . to . have . been . calledWith ( sinon . match . string ) ;
221- expect ( result ) . to . equal ( `abc ${ path . sep } codeql.exe` ) ;
225+ expect ( result ) . to . equal ( pathToExe ) ;
222226 } ) ;
223227
224228 it ( 'should warn when using a hard-coded deprecated launcher name' , async ( ) => {
225229 launcherThatExists = 'codeql.cmd' ;
226230 path . sep ;
227231 const result = await getExecutableFromDirectory ( 'abc' ) ;
228- expect ( fsSpy ) . to . have . been . calledWith ( `abc ${ path . sep } codeql.exe` ) ;
229- expect ( fsSpy ) . to . have . been . calledWith ( `abc ${ path . sep } codeql.cmd` ) ;
232+ expect ( fsSpy ) . to . have . been . calledWith ( pathToExe ) ;
233+ expect ( fsSpy ) . to . have . been . calledWith ( pathToCmd ) ;
230234
231235 // Should have opened a warning message
232236 expect ( warnSpy ) . to . have . been . calledWith ( sinon . match . string ) ;
233237 // No log message
234238 expect ( logSpy ) . not . to . have . been . calledWith ( sinon . match . string ) ;
235- expect ( result ) . to . equal ( `abc ${ path . sep } codeql.cmd` ) ;
239+ expect ( result ) . to . equal ( pathToCmd ) ;
236240 } ) ;
237241
238242 it ( 'should avoid warn when no launcher is found' , async ( ) => {
239243 launcherThatExists = 'xxx' ;
240244 const result = await getExecutableFromDirectory ( 'abc' , false ) ;
241- expect ( fsSpy ) . to . have . been . calledWith ( `abc ${ path . sep } codeql.exe` ) ;
242- expect ( fsSpy ) . to . have . been . calledWith ( `abc ${ path . sep } codeql.cmd` ) ;
245+ expect ( fsSpy ) . to . have . been . calledWith ( pathToExe ) ;
246+ expect ( fsSpy ) . to . have . been . calledWith ( pathToCmd ) ;
243247
244248 // no warning message
245249 expect ( warnSpy ) . not . to . have . been . calledWith ( sinon . match . string ) ;
@@ -251,8 +255,8 @@ describe('Launcher path', () => {
251255 it ( 'should warn when no launcher is found' , async ( ) => {
252256 launcherThatExists = 'xxx' ;
253257 const result = await getExecutableFromDirectory ( 'abc' , true ) ;
254- expect ( fsSpy ) . to . have . been . calledWith ( `abc ${ path . sep } codeql.exe` ) ;
255- expect ( fsSpy ) . to . have . been . calledWith ( `abc ${ path . sep } codeql.cmd` ) ;
258+ expect ( fsSpy ) . to . have . been . calledWith ( pathToExe ) ;
259+ expect ( fsSpy ) . to . have . been . calledWith ( pathToCmd ) ;
256260
257261 // no warning message
258262 expect ( warnSpy ) . not . to . have . been . calledWith ( sinon . match . string ) ;
@@ -261,17 +265,55 @@ describe('Launcher path', () => {
261265 expect ( result ) . to . equal ( undefined ) ;
262266 } ) ;
263267
268+ it ( 'should not warn when deprecated launcher is used, but no new launcher is available' , async ( ) => {
269+ const manager = new ( createModule ( ) . DistributionManager ) ( undefined as any , { customCodeQlPath : pathToCmd } as any , undefined as any ) ;
270+ launcherThatExists = 'codeql.cmd' ;
271+
272+ const result = await manager . getCodeQlPathWithoutVersionCheck ( ) ;
273+ expect ( result ) . to . equal ( pathToCmd ) ;
274+
275+ // no warning or error message
276+ expect ( warnSpy ) . to . have . callCount ( 0 ) ;
277+ expect ( errorSpy ) . to . have . callCount ( 0 ) ;
278+ } ) ;
279+
280+ it ( 'should warn when deprecated launcher is used, and new launcher is available' , async ( ) => {
281+ const manager = new ( createModule ( ) . DistributionManager ) ( undefined as any , { customCodeQlPath : pathToCmd } as any , undefined as any ) ;
282+ launcherThatExists = '' ; // pretend both launchers exist
283+
284+ const result = await manager . getCodeQlPathWithoutVersionCheck ( ) ;
285+ expect ( result ) . to . equal ( pathToCmd ) ;
286+
287+ // has warning message
288+ expect ( warnSpy ) . to . have . callCount ( 1 ) ;
289+ expect ( errorSpy ) . to . have . callCount ( 0 ) ;
290+ } ) ;
291+
292+ it ( 'should warn when launcher path is incorrect' , async ( ) => {
293+ const manager = new ( createModule ( ) . DistributionManager ) ( undefined as any , { customCodeQlPath : pathToCmd } as any , undefined as any ) ;
294+ launcherThatExists = 'xxx' ; // pretend neither launcher exists
295+
296+ const result = await manager . getCodeQlPathWithoutVersionCheck ( ) ;
297+ expect ( result ) . to . equal ( undefined ) ;
298+
299+ // no error message
300+ expect ( warnSpy ) . to . have . callCount ( 0 ) ;
301+ expect ( errorSpy ) . to . have . callCount ( 1 ) ;
302+ } ) ;
303+
264304 function createModule ( ) {
265305 sandbox = sinon . createSandbox ( ) ;
266306 warnSpy = sandbox . spy ( ) ;
307+ errorSpy = sandbox . spy ( ) ;
267308 logSpy = sandbox . spy ( ) ;
268309 // pretend that only the .cmd file exists
269310 fsSpy = sandbox . stub ( ) . callsFake ( arg => arg . endsWith ( launcherThatExists ) ? true : false ) ;
270311 platformSpy = sandbox . stub ( ) . returns ( 'win32' ) ;
271312
272313 return proxyquire ( '../../distribution' , {
273314 './helpers' : {
274- showAndLogWarningMessage : warnSpy
315+ showAndLogWarningMessage : warnSpy ,
316+ showAndLogErrorMessage : errorSpy
275317 } ,
276318 './logging' : {
277319 'logger' : {
0 commit comments