@@ -240,25 +240,130 @@ suite('Kits scan test', () => {
240240 } ) . timeout ( 10000 ) ;
241241 } ) ;
242242
243- suite ( 'VS Generator mapping' , ( ) => {
244- test ( 'returns correct generator for VS 2022' , ( ) => {
245- expect ( kit . vsGeneratorForVersion ( '17' ) ) . to . eq ( 'Visual Studio 17 2022' ) ;
243+ suite ( 'Kit change detection for generator regression (#4890)' , ( ) => {
244+ // These tests verify kitChangeNeedsClean correctly detects generator-related
245+ // kit changes, which is the safety net for the regression fixed in #4890.
246+
247+ test ( 'Returns false for null old kit (first kit selection)' , ( ) => {
248+ const newKit : kit . Kit = {
249+ name : 'Visual Studio Community 2026 Release - amd64' ,
250+ visualStudio : 'VisualStudio.18.0' ,
251+ visualStudioArchitecture : 'x64' ,
252+ isTrusted : true ,
253+ preferredGenerator : {
254+ name : 'Visual Studio 18 2026' ,
255+ platform : 'x64' ,
256+ toolset : 'host=x64'
257+ }
258+ } ;
259+ expect ( kit . kitChangeNeedsClean ( newKit , null ) ) . to . be . false ;
246260 } ) ;
247261
248- test ( 'returns correct generator for VS 2026' , ( ) => {
249- expect ( kit . vsGeneratorForVersion ( '18' ) ) . to . eq ( 'Visual Studio 18 2026' ) ;
262+ test ( 'Returns true when preferredGenerator changes from undefined to VS generator' , ( ) => {
263+ const oldKit : kit . Kit = {
264+ name : 'Visual Studio Community 2026 Release - amd64' ,
265+ visualStudio : 'VisualStudio.18.0' ,
266+ visualStudioArchitecture : 'x64' ,
267+ isTrusted : true
268+ // preferredGenerator is undefined — simulates kit scanned before VS 2026 mapping
269+ } ;
270+ const newKit : kit . Kit = {
271+ name : 'Visual Studio Community 2026 Release - amd64' ,
272+ visualStudio : 'VisualStudio.18.0' ,
273+ visualStudioArchitecture : 'x64' ,
274+ isTrusted : true ,
275+ preferredGenerator : {
276+ name : 'Visual Studio 18 2026' ,
277+ platform : 'x64' ,
278+ toolset : 'host=x64'
279+ }
280+ } ;
281+ expect ( kit . kitChangeNeedsClean ( newKit , oldKit ) ) . to . be . true ;
282+ } ) ;
283+
284+ test ( 'Returns false when kits have identical preferredGenerator' , ( ) => {
285+ const generator = {
286+ name : 'Visual Studio 18 2026' ,
287+ platform : 'x64' ,
288+ toolset : 'host=x64'
289+ } ;
290+ const oldKit : kit . Kit = {
291+ name : 'Visual Studio Community 2026 Release - amd64' ,
292+ visualStudio : 'VisualStudio.18.0' ,
293+ visualStudioArchitecture : 'x64' ,
294+ isTrusted : true ,
295+ preferredGenerator : { ...generator }
296+ } ;
297+ const newKit : kit . Kit = {
298+ name : 'Visual Studio Community 2026 Release - amd64' ,
299+ visualStudio : 'VisualStudio.18.0' ,
300+ visualStudioArchitecture : 'x64' ,
301+ isTrusted : true ,
302+ preferredGenerator : { ...generator }
303+ } ;
304+ expect ( kit . kitChangeNeedsClean ( newKit , oldKit ) ) . to . be . false ;
250305 } ) ;
251306
252- test ( 'returns correct generator for VS 2019' , ( ) => {
253- expect ( kit . vsGeneratorForVersion ( '16' ) ) . to . eq ( 'Visual Studio 16 2019' ) ;
307+ test ( 'Returns true when switching from VS generator to no generator' , ( ) => {
308+ const oldKit : kit . Kit = {
309+ name : 'Visual Studio Community 2026 Release - amd64' ,
310+ visualStudio : 'VisualStudio.18.0' ,
311+ visualStudioArchitecture : 'x64' ,
312+ isTrusted : true ,
313+ preferredGenerator : {
314+ name : 'Visual Studio 18 2026' ,
315+ platform : 'x64' ,
316+ toolset : 'host=x64'
317+ }
318+ } ;
319+ const newKit : kit . Kit = {
320+ name : 'GCC 12.0.0' ,
321+ isTrusted : true
322+ // No preferredGenerator — typical GCC kit uses Ninja default
323+ } ;
324+ expect ( kit . kitChangeNeedsClean ( newKit , oldKit ) ) . to . be . true ;
254325 } ) ;
255326
256- test ( 'returns undefined for unknown version' , ( ) => {
257- expect ( kit . vsGeneratorForVersion ( '99' ) ) . to . be . undefined ;
327+ test ( 'Returns true when generator name changes between VS versions' , ( ) => {
328+ const oldKit : kit . Kit = {
329+ name : 'Visual Studio Community 2022 Release - amd64' ,
330+ visualStudio : 'VisualStudio.17.0' ,
331+ visualStudioArchitecture : 'x64' ,
332+ isTrusted : true ,
333+ preferredGenerator : {
334+ name : 'Visual Studio 17 2022' ,
335+ platform : 'x64' ,
336+ toolset : 'host=x64'
337+ }
338+ } ;
339+ const newKit : kit . Kit = {
340+ name : 'Visual Studio Community 2026 Release - amd64' ,
341+ visualStudio : 'VisualStudio.18.0' ,
342+ visualStudioArchitecture : 'x64' ,
343+ isTrusted : true ,
344+ preferredGenerator : {
345+ name : 'Visual Studio 18 2026' ,
346+ platform : 'x64' ,
347+ toolset : 'host=x64'
348+ }
349+ } ;
350+ expect ( kit . kitChangeNeedsClean ( newKit , oldKit ) ) . to . be . true ;
258351 } ) ;
259352
260- test ( 'returns correct generator for legacy VS120COMNTOOLS' , ( ) => {
261- expect ( kit . vsGeneratorForVersion ( 'VS120COMNTOOLS' ) ) . to . eq ( 'Visual Studio 12 2013' ) ;
353+ test ( 'Returns false when both kits have no preferredGenerator' , ( ) => {
354+ const oldKit : kit . Kit = {
355+ name : 'Visual Studio Community 2026 Release - amd64' ,
356+ visualStudio : 'VisualStudio.18.0' ,
357+ visualStudioArchitecture : 'x64' ,
358+ isTrusted : true
359+ } ;
360+ const newKit : kit . Kit = {
361+ name : 'Visual Studio Community 2026 Release - amd64' ,
362+ visualStudio : 'VisualStudio.18.0' ,
363+ visualStudioArchitecture : 'x64' ,
364+ isTrusted : true
365+ } ;
366+ expect ( kit . kitChangeNeedsClean ( newKit , oldKit ) ) . to . be . false ;
262367 } ) ;
263368 } ) ;
264369
0 commit comments