Skip to content

Commit e117457

Browse files
authored
Fix failing capture diagnostics test (#1769)
* Fix failing capture diagnostics test * Ignore DAP logs prior to 6.0 * Also ignore LSP logs for earlier versions
1 parent 401c3a3 commit e117457

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

test/integration-tests/commands/captureDiagnostics.test.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
folderInRootWorkspace,
2727
updateSettings,
2828
} from "../utilities/testutilities";
29+
import { Version } from "../../../src/utilities/version";
2930

3031
suite("captureDiagnostics Test Suite", () => {
3132
let workspaceContext: WorkspaceContext;
@@ -117,16 +118,20 @@ suite("captureDiagnostics Test Suite", () => {
117118

118119
const { files, folder } = await decompressZip(zipPath as string);
119120

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+
120127
validate(
121128
files.map(file => file.path),
122129
[
123130
"swift-vscode-extension.log",
124-
"defaultPackage-[a-z0-9]+-diagnostics.txt",
125131
"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
130135
);
131136

132137
await rm(folder, { recursive: true, force: true });
@@ -142,21 +147,30 @@ suite("captureDiagnostics Test Suite", () => {
142147
expect(zipPath).to.not.be.undefined;
143148

144149
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+
145163
validate(
146164
files.map(file => file.path),
147165
[
148166
"swift-vscode-extension.log",
149167
"defaultPackage/",
150-
"defaultPackage/defaultPackage-[a-z0-9]+-diagnostics.txt",
151168
"defaultPackage/defaultPackage-[a-z0-9]+-settings.txt",
152-
"defaultPackage/sourcekit-lsp/",
153169
"dependencies/",
154-
"dependencies/dependencies-[a-z0-9]+-diagnostics.txt",
155170
"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
160174
);
161175
await rm(folder, { recursive: true, force: true });
162176
});
@@ -174,11 +188,13 @@ suite("captureDiagnostics Test Suite", () => {
174188
return { folder: tempDir, files: await decompress(zipPath as string, tempDir) };
175189
}
176190

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+
}
182198
const regexes = patterns.map(pattern => new RegExp(`^${pattern}$`));
183199
for (const regex of regexes) {
184200
const matched = paths.some(path => regex.test(path));

0 commit comments

Comments
 (0)