@@ -163,6 +163,7 @@ suite('CppTools tests', () => {
163
163
expect ( mode ) . to . eql ( 'clang-x86' ) ;
164
164
} ) ;
165
165
166
+ // Validate codeModel using cppTools API V6
166
167
test ( 'Validate code model' , async ( ) => {
167
168
const provider = new CppConfigurationProvider ( ) ;
168
169
const cache = await CMakeCache . fromPath ( getTestResourceFilePath ( 'TestCMakeCache.txt' ) ) ;
@@ -181,7 +182,8 @@ suite('CppTools tests', () => {
181
182
fileGroups : [ {
182
183
sources : [ sourceFile ] ,
183
184
isGenerated : false ,
184
- compileCommandFragments : [ '-DFLAG1' ] ,
185
+ defines : [ 'DEFINE1' ] ,
186
+ compileCommandFragments : [ '-DFRAGMENT1' ] ,
185
187
language : 'CXX'
186
188
} ]
187
189
} ,
@@ -191,7 +193,8 @@ suite('CppTools tests', () => {
191
193
fileGroups : [ {
192
194
sources : [ sourceFile ] ,
193
195
isGenerated : false ,
194
- compileCommandFragments : [ '-DFLAG2' ] ,
196
+ defines : [ 'DEFINE2' ] ,
197
+ compileCommandFragments : [ '-DFRAGMENT2' ] ,
195
198
language : 'CXX'
196
199
} ]
197
200
}
@@ -220,7 +223,8 @@ suite('CppTools tests', () => {
220
223
fileGroups : [ {
221
224
sources : [ sourceFile2 ] ,
222
225
isGenerated : false ,
223
- compileCommandFragments : [ '-DFLAG3' ] ,
226
+ defines : [ 'DEFINE3' ] ,
227
+ compileCommandFragments : [ '-DFRAGMENT3' ] ,
224
228
language : 'CXX'
225
229
} ]
226
230
} ]
@@ -236,19 +240,22 @@ suite('CppTools tests', () => {
236
240
237
241
configurations = await provider . provideConfigurations ( [ uri ] ) ;
238
242
expect ( configurations . length ) . to . eq ( 1 ) ;
239
- expect ( configurations [ 0 ] . configuration . defines ) . to . contain ( 'FLAG1' ) ;
243
+ expect ( configurations [ 0 ] . configuration . defines ) . to . eq ( 'DEFINE3' ) ;
244
+ expect ( configurations [ 0 ] . configuration . compilerFragments ) . to . contain ( '-DFRAGMENT3' ) ;
245
+ expect ( configurations [ 0 ] . configuration . compilerArgs ) . to . eq ( undefined ) ;
240
246
241
247
provider . updateConfigurationData ( { cache, codeModelContent, activeTarget : 'target2' , activeBuildTypeVariant : 'Release' , folder : here } ) ;
242
248
configurations = await provider . provideConfigurations ( [ uri ] ) ;
243
249
expect ( configurations . length ) . to . eq ( 1 ) ;
244
- expect ( configurations [ 0 ] . configuration . defines ) . to . contain ( 'FLAG2' ) ;
250
+ expect ( configurations [ 0 ] . configuration . defines ) . to . eq ( 'DEFINE2' ) ;
251
+ expect ( configurations [ 0 ] . configuration . compilerFragments ) . to . contain ( '-DFRAGMENT2' ) ;
245
252
expect ( configurations [ 0 ] . configuration . compilerPath ) . to . eq ( 'clang++' ) ;
246
253
247
254
provider . updateConfigurationData ( { cache, codeModelContent, activeTarget : 'all' , activeBuildTypeVariant : 'Release' , folder : here } ) ;
248
255
configurations = await provider . provideConfigurations ( [ uri ] ) ;
249
256
expect ( configurations . length ) . to . eq ( 1 ) ;
250
- expect ( configurations [ 0 ] . configuration . defines . some ( def => def === 'FLAG1 ' || def === 'FLAG2 ' ) ) . to . be . true ;
251
- expect ( configurations [ 0 ] . configuration . defines ) . to . not . have . all . members ( [ 'FLAG1 ' , 'FLAG2 ' ] ) ;
257
+ expect ( configurations [ 0 ] . configuration . defines . some ( def => def === 'DEFINE1 ' || def === 'DEFINE2 ' ) ) . to . be . true ;
258
+ expect ( configurations [ 0 ] . configuration . defines ) . to . not . have . all . members ( [ 'DEFINE1 ' , 'DEFINE2 ' ] ) ;
252
259
253
260
// Verify the per-folder browsePath.
254
261
const canProvideBrowseConfigPerFolder : boolean = await provider . canProvideBrowseConfigurationsPerFolder ( ) ;
@@ -260,7 +267,7 @@ suite('CppTools tests', () => {
260
267
// Verify the browsePath with a different folder.
261
268
const configurations2 = await provider . provideConfigurations ( [ uri2 ] ) ;
262
269
expect ( configurations2 . length ) . to . eq ( 1 ) ;
263
- expect ( configurations2 [ 0 ] . configuration . defines ) . to . contain ( 'FLAG3 ' ) ;
270
+ expect ( configurations2 [ 0 ] . configuration . defines ) . to . contain ( 'DEFINE3 ' ) ;
264
271
const browseConfig2 = await provider . provideFolderBrowseConfiguration ( vscode . Uri . file ( smokeFolder ) ) ;
265
272
expect ( browseConfig2 . browsePath . length ) . to . eq ( 1 ) ;
266
273
expect ( browseConfig2 . browsePath [ 0 ] ) . to . eq ( util . platformNormalizePath ( smokeFolder ) ) ;
0 commit comments