@@ -26,6 +26,7 @@ import {
26
26
folderInRootWorkspace ,
27
27
updateSettings ,
28
28
} from "../utilities/testutilities" ;
29
+ import { Version } from "../../../src/utilities/version" ;
29
30
30
31
suite ( "captureDiagnostics Test Suite" , ( ) => {
31
32
let workspaceContext : WorkspaceContext ;
@@ -117,16 +118,20 @@ suite("captureDiagnostics Test Suite", () => {
117
118
118
119
const { files, folder } = await decompressZip ( zipPath as string ) ;
119
120
121
+ const post60Logs = workspaceContext . globalToolchainSwiftVersion . isGreaterThanOrEqual (
122
+ new Version ( 6 , 0 , 0 )
123
+ )
124
+ ? [ "sourcekit-lsp/" , "lldb-dap-session-123456789.log" , "LLDB-DAP.log" ]
125
+ : [ ] ;
126
+
120
127
validate (
121
128
files . map ( file => file . path ) ,
122
129
[
123
130
"swift-vscode-extension.log" ,
124
- "defaultPackage-[a-z0-9]+-diagnostics.txt" ,
125
131
"defaultPackage-[a-z0-9]+-settings.txt" ,
126
- "lldb-dap-session-123456789.log" ,
127
- "sourcekit-lsp/" ,
128
- "LLDB-DAP.log" ,
129
- ]
132
+ ...post60Logs ,
133
+ ] ,
134
+ false // Sometime are diagnostics, sometimes not but not point of this test
130
135
) ;
131
136
132
137
await rm ( folder , { recursive : true , force : true } ) ;
@@ -142,21 +147,30 @@ suite("captureDiagnostics Test Suite", () => {
142
147
expect ( zipPath ) . to . not . be . undefined ;
143
148
144
149
const { files, folder } = await decompressZip ( zipPath as string ) ;
150
+
151
+ const post60Logs =
152
+ workspaceContext . globalToolchainSwiftVersion . isGreaterThanOrEqual (
153
+ new Version ( 6 , 0 , 0 )
154
+ )
155
+ ? [
156
+ "dependencies/sourcekit-lsp/" ,
157
+ "LLDB-DAP.log" ,
158
+ "lldb-dap-session-123456789.log" ,
159
+ "defaultPackage/sourcekit-lsp/" ,
160
+ ]
161
+ : [ ] ;
162
+
145
163
validate (
146
164
files . map ( file => file . path ) ,
147
165
[
148
166
"swift-vscode-extension.log" ,
149
167
"defaultPackage/" ,
150
- "defaultPackage/defaultPackage-[a-z0-9]+-diagnostics.txt" ,
151
168
"defaultPackage/defaultPackage-[a-z0-9]+-settings.txt" ,
152
- "defaultPackage/sourcekit-lsp/" ,
153
169
"dependencies/" ,
154
- "dependencies/dependencies-[a-z0-9]+-diagnostics.txt" ,
155
170
"dependencies/dependencies-[a-z0-9]+-settings.txt" ,
156
- "dependencies/sourcekit-lsp/" ,
157
- "LLDB-DAP.log" ,
158
- "lldb-dap-session-123456789.log" ,
159
- ]
171
+ ...post60Logs ,
172
+ ] ,
173
+ false // Sometime are diagnostics, sometimes not but not point of this test
160
174
) ;
161
175
await rm ( folder , { recursive : true , force : true } ) ;
162
176
} ) ;
@@ -174,11 +188,13 @@ suite("captureDiagnostics Test Suite", () => {
174
188
return { folder : tempDir , files : await decompress ( zipPath as string , tempDir ) } ;
175
189
}
176
190
177
- function validate ( paths : string [ ] , patterns : string [ ] ) : void {
178
- expect ( paths . length ) . to . equal (
179
- patterns . length ,
180
- `Expected ${ patterns . length } files: ${ JSON . stringify ( patterns ) } \n\n...but found ${ paths . length } : ${ JSON . stringify ( paths ) } `
181
- ) ;
191
+ function validate ( paths : string [ ] , patterns : string [ ] , matchCount : boolean = true ) : void {
192
+ if ( matchCount ) {
193
+ expect ( paths . length ) . to . equal (
194
+ patterns . length ,
195
+ `Expected ${ patterns . length } files: ${ JSON . stringify ( patterns ) } \n\n...but found ${ paths . length } : ${ JSON . stringify ( paths ) } `
196
+ ) ;
197
+ }
182
198
const regexes = patterns . map ( pattern => new RegExp ( `^${ pattern } $` ) ) ;
183
199
for ( const regex of regexes ) {
184
200
const matched = paths . some ( path => regex . test ( path ) ) ;
0 commit comments