-
Notifications
You must be signed in to change notification settings - Fork 526
Enhance generator mismatch detection and clean-up logic #4892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8df6da2
Enhance generator mismatch detection and clean-up logic
hanniavalera b802b56
updating documentation
hanniavalera d3d6669
improve Visual Studio generator handling and add tests for version ma…
hanniavalera de22e10
Merge branch 'main' into dev/hanniavalera/fixConfigGen
hanniavalera bf8b733
took in more feedback
hanniavalera bbae201
Merge branch 'main' into dev/hanniavalera/fixConfigGen
hanniavalera 42786ef
Merge branch 'main' into dev/hanniavalera/fixConfigGen
hanniavalera b7ced89
Merge branch 'main' into dev/hanniavalera/fixConfigGen
hanniavalera a33e240
adjust changelog
hanniavalera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* eslint-disable no-unused-expressions */ | ||
| import { expect } from 'chai'; | ||
| import { CMakeCache, CacheEntry } from '@cmt/cache'; | ||
| import { generatorMismatch } from '@cmt/drivers/cmakeDriver'; | ||
|
|
||
| suite('Generator mismatch detection', () => { | ||
| suite('generatorMismatch (pure helper)', () => { | ||
| test('Returns true when generators differ', () => { | ||
| expect(generatorMismatch('Visual Studio 18 2026', 'Ninja')).to.be.true; | ||
| }); | ||
|
|
||
| test('Returns false when generators match', () => { | ||
| expect(generatorMismatch('Ninja', 'Ninja')).to.be.false; | ||
| }); | ||
|
|
||
| test('Returns false when new generator is undefined', () => { | ||
| expect(generatorMismatch(undefined, 'Ninja')).to.be.false; | ||
| }); | ||
|
|
||
| test('Returns false when cached generator is undefined', () => { | ||
| expect(generatorMismatch('Ninja', undefined)).to.be.false; | ||
| }); | ||
|
|
||
| test('Returns false when both are undefined', () => { | ||
| expect(generatorMismatch(undefined, undefined)).to.be.false; | ||
| }); | ||
|
|
||
| test('Returns false when cached value is empty string', () => { | ||
| expect(generatorMismatch('Ninja', '')).to.be.false; | ||
| }); | ||
|
|
||
| test('Returns true for different VS versions', () => { | ||
| expect(generatorMismatch('Visual Studio 18 2026', 'Visual Studio 17 2022')).to.be.true; | ||
| }); | ||
|
|
||
| test('Returns true switching from VS generator to Ninja', () => { | ||
| expect(generatorMismatch('Ninja', 'Visual Studio 18 2026')).to.be.true; | ||
| }); | ||
|
|
||
| test('Returns true switching from Unix Makefiles to Ninja', () => { | ||
| expect(generatorMismatch('Ninja', 'Unix Makefiles')).to.be.true; | ||
| }); | ||
| }); | ||
|
|
||
| suite('CMakeCache.parseCache integration', () => { | ||
| test('Detects mismatch via parsed cache (Ninja cached, VS selected)', () => { | ||
| const cacheContent = [ | ||
| '# This is the CMakeCache file.', | ||
| 'CMAKE_GENERATOR:INTERNAL=Ninja', | ||
| '' | ||
| ].join('\n'); | ||
| const entries = CMakeCache.parseCache(cacheContent); | ||
| const cachedGenerator = entries.get('CMAKE_GENERATOR') as CacheEntry; | ||
| expect(generatorMismatch('Visual Studio 18 2026', cachedGenerator.value)).to.be.true; | ||
| }); | ||
|
|
||
| test('No mismatch when cached generator matches selected', () => { | ||
| const cacheContent = 'CMAKE_GENERATOR:INTERNAL=Ninja\n'; | ||
| const entries = CMakeCache.parseCache(cacheContent); | ||
| const cachedGenerator = entries.get('CMAKE_GENERATOR') as CacheEntry; | ||
| expect(generatorMismatch('Ninja', cachedGenerator.value)).to.be.false; | ||
| }); | ||
|
|
||
| test('No mismatch when CMAKE_GENERATOR absent from cache', () => { | ||
| const cacheContent = 'CMAKE_BUILD_TYPE:STRING=Debug\n'; | ||
| const entries = CMakeCache.parseCache(cacheContent); | ||
| const cachedGenerator = entries.get('CMAKE_GENERATOR'); | ||
| expect(generatorMismatch('Ninja', cachedGenerator?.value)).to.be.false; | ||
| }); | ||
|
|
||
| test('No mismatch when cache is empty', () => { | ||
| const entries = CMakeCache.parseCache(''); | ||
| const cachedGenerator = entries.get('CMAKE_GENERATOR'); | ||
| expect(generatorMismatch('Ninja', cachedGenerator?.value)).to.be.false; | ||
| }); | ||
|
|
||
| test('Detects mismatch between two VS generator versions via cache', () => { | ||
| const cacheContent = 'CMAKE_GENERATOR:INTERNAL=Visual Studio 17 2022\n'; | ||
| const entries = CMakeCache.parseCache(cacheContent); | ||
| const cachedGenerator = entries.get('CMAKE_GENERATOR') as CacheEntry; | ||
| expect(generatorMismatch('Visual Studio 18 2026', cachedGenerator.value)).to.be.true; | ||
| }); | ||
|
|
||
| test('Detects mismatch when switching from Unix Makefiles cached to Ninja', () => { | ||
| const cacheContent = 'CMAKE_GENERATOR:INTERNAL=Unix Makefiles\n'; | ||
| const entries = CMakeCache.parseCache(cacheContent); | ||
| const cachedGenerator = entries.get('CMAKE_GENERATOR') as CacheEntry; | ||
| expect(generatorMismatch('Ninja', cachedGenerator.value)).to.be.true; | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.