@@ -22,6 +22,12 @@ describe('registerRelatedFilesProvider', () => {
22
22
let callbackPromise : Promise < { entries : vscode . Uri [ ] ; traits ?: CopilotTrait [ ] } > | undefined ;
23
23
let vscodeExtension : vscode . Extension < unknown > ;
24
24
25
+ const includedFiles = process . platform === 'win32' ?
26
+ [ 'c:\\system\\include\\vector' , 'c:\\system\\include\\string' , 'C:\\src\\my_project\\foo.h' ] :
27
+ [ '/system/include/vector' , '/system/include/string' , '/home/src/my_project/foo.h' ] ;
28
+ const rootUri = vscode . Uri . file ( process . platform === 'win32' ? 'C:\\src\\my_project' : '/home/src/my_project' ) ;
29
+ const expectedInclude = process . platform === 'win32' ? 'file:///c%3A/src/my_project/foo.h' : 'file:///home/src/my_project/foo.h' ;
30
+
25
31
beforeEach ( ( ) => {
26
32
proxyquire . noPreserveCache ( ) ; // Tells proxyquire to not fetch the module from cache
27
33
// Ensures that each test has a freshly loaded instance of moduleUnderTest
@@ -105,9 +111,9 @@ describe('registerRelatedFilesProvider', () => {
105
111
it ( 'should not add #cpp traits when ChatContext isn\'t available.' , async ( ) => {
106
112
arrange ( {
107
113
vscodeExtension : vscodeExtension ,
108
- getIncludeFiles : { includedFiles : [ 'c:\\system\\include\\vector' , 'c:\\system\\include\\string' , 'C:\\src\\my_project\\foo.h' ] } ,
114
+ getIncludeFiles : { includedFiles } ,
109
115
chatContext : undefined ,
110
- rootUri : vscode . Uri . file ( 'C:\\src\\my_project' ) ,
116
+ rootUri,
111
117
flags : { copilotcppTraits : true }
112
118
} ) ;
113
119
await moduleUnderTest . registerRelatedFilesProvider ( ) ;
@@ -120,22 +126,22 @@ describe('registerRelatedFilesProvider', () => {
120
126
ok ( callbackPromise , 'callbackPromise should be defined' ) ;
121
127
ok ( result , 'result should be defined' ) ;
122
128
ok ( result . entries . length === 1 , 'result.entries should have 1 included file' ) ;
123
- ok ( result . entries [ 0 ] . toString ( ) === 'file:///c%3A/src/my_project/foo.h' , ' result.entries should have "file:///c%3A/src/my_project/foo.h"' ) ;
129
+ ok ( result . entries [ 0 ] . toString ( ) === expectedInclude , ` result.entries should have "${ expectedInclude } "` ) ;
124
130
ok ( result . traits === undefined , 'result.traits should be undefined' ) ;
125
131
} ) ;
126
132
127
133
it ( 'should not add #cpp traits when copilotcppTraits flag is false.' , async ( ) => {
128
134
arrange ( {
129
135
vscodeExtension : vscodeExtension ,
130
- getIncludeFiles : { includedFiles : [ 'c:\\system\\include\\vector' , 'c:\\system\\include\\string' , 'C:\\src\\my_project\\foo.h' ] } ,
136
+ getIncludeFiles : { includedFiles } ,
131
137
chatContext : {
132
138
language : 'c++' ,
133
139
standardVersion : 'c++20' ,
134
140
compiler : 'msvc' ,
135
141
targetPlatform : 'windows' ,
136
142
targetArchitecture : 'x64'
137
143
} ,
138
- rootUri : vscode . Uri . file ( 'C:\\src\\my_project' ) ,
144
+ rootUri,
139
145
flags : { copilotcppTraits : false }
140
146
} ) ;
141
147
await moduleUnderTest . registerRelatedFilesProvider ( ) ;
@@ -148,22 +154,22 @@ describe('registerRelatedFilesProvider', () => {
148
154
ok ( callbackPromise , 'callbackPromise should be defined' ) ;
149
155
ok ( result , 'result should be defined' ) ;
150
156
ok ( result . entries . length === 1 , 'result.entries should have 1 included file' ) ;
151
- ok ( result . entries [ 0 ] . toString ( ) === 'file:///c%3A/src/my_project/foo.h' , ' result.entries should have "file:///c%3A/src/my_project/foo.h"' ) ;
157
+ ok ( result . entries [ 0 ] . toString ( ) === expectedInclude , ` result.entries should have "${ expectedInclude } "` ) ;
152
158
ok ( result . traits === undefined , 'result.traits should be undefined' ) ;
153
159
} ) ;
154
160
155
161
it ( 'should add #cpp traits when copilotcppTraits flag is true.' , async ( ) => {
156
162
arrange ( {
157
163
vscodeExtension : vscodeExtension ,
158
- getIncludeFiles : { includedFiles : [ 'c:\\system\\include\\vector' , 'c:\\system\\include\\string' , 'C:\\src\\my_project\\foo.h' ] } ,
164
+ getIncludeFiles : { includedFiles } ,
159
165
chatContext : {
160
166
language : 'c++' ,
161
167
standardVersion : 'c++20' ,
162
168
compiler : 'msvc' ,
163
169
targetPlatform : 'windows' ,
164
170
targetArchitecture : 'x64'
165
171
} ,
166
- rootUri : vscode . Uri . file ( 'C:\\src\\my_project' ) ,
172
+ rootUri,
167
173
flags : { copilotcppTraits : true }
168
174
} ) ;
169
175
await moduleUnderTest . registerRelatedFilesProvider ( ) ;
@@ -177,7 +183,7 @@ describe('registerRelatedFilesProvider', () => {
177
183
ok ( callbackPromise , 'callbackPromise should be defined' ) ;
178
184
ok ( result , 'result should be defined' ) ;
179
185
ok ( result . entries . length === 1 , 'result.entries should have 1 included file' ) ;
180
- ok ( result . entries [ 0 ] . toString ( ) === 'file:///c%3A/src/my_project/foo.h' , ' result.entries should have "file:///c%3A/src/my_project/foo.h"' ) ;
186
+ ok ( result . entries [ 0 ] . toString ( ) === expectedInclude , ` result.entries should have "${ expectedInclude } "` ) ;
181
187
ok ( result . traits , 'result.traits should be defined' ) ;
182
188
ok ( result . traits . length === 5 , 'result.traits should have 5 traits' ) ;
183
189
ok ( result . traits [ 0 ] . name === 'language' , 'result.traits[0].name should be "language"' ) ;
@@ -206,15 +212,15 @@ describe('registerRelatedFilesProvider', () => {
206
212
const excludeTraits = [ 'compiler' , 'targetPlatform' ] ;
207
213
arrange ( {
208
214
vscodeExtension : vscodeExtension ,
209
- getIncludeFiles : { includedFiles : [ 'c:\\system\\include\\vector' , 'c:\\system\\include\\string' , 'C:\\src\\my_project\\foo.h' ] } ,
215
+ getIncludeFiles : { includedFiles } ,
210
216
chatContext : {
211
217
language : 'c++' ,
212
218
standardVersion : 'c++20' ,
213
219
compiler : 'msvc' ,
214
220
targetPlatform : 'windows' ,
215
221
targetArchitecture : 'x64'
216
222
} ,
217
- rootUri : vscode . Uri . file ( 'C:\\src\\my_project' ) ,
223
+ rootUri,
218
224
flags : { copilotcppTraits : true , copilotcppExcludeTraits : excludeTraits }
219
225
} ) ;
220
226
await moduleUnderTest . registerRelatedFilesProvider ( ) ;
@@ -228,7 +234,7 @@ describe('registerRelatedFilesProvider', () => {
228
234
ok ( callbackPromise , 'callbackPromise should be defined' ) ;
229
235
ok ( result , 'result should be defined' ) ;
230
236
ok ( result . entries . length === 1 , 'result.entries should have 1 included file' ) ;
231
- ok ( result . entries [ 0 ] . toString ( ) === 'file:///c%3A/src/my_project/foo.h' , ' result.entries should have "file:///c%3A/src/my_project/foo.h"' ) ;
237
+ ok ( result . entries [ 0 ] . toString ( ) === expectedInclude , ` result.entries should have "${ expectedInclude } "` ) ;
232
238
ok ( result . traits , 'result.traits should be defined' ) ;
233
239
ok ( result . traits . length === 3 , 'result.traits should have 3 traits' ) ;
234
240
ok ( result . traits . filter ( trait => excludeTraits . includes ( trait . name ) ) . length === 0 , 'result.traits should not include excluded traits' ) ;
0 commit comments