Skip to content

Commit 7cf92ff

Browse files
authored
Merge pull request #1 from swiftlang/main
update
2 parents ec4f82c + 5572877 commit 7cf92ff

File tree

17 files changed

+372
-54
lines changed

17 files changed

+372
-54
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md -text merge=union

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md renamed to .github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@ contributing guidelines for any contributions -->
55
it on the forums or on Slack. This ensures that you don't waste any time working on contributions that
66
won't get accepted! -->
77

8-
<!-- Describe your changes clearly and use examples if possible. Please link to any GitHub issue if applicable -->
8+
## Description
9+
Describe your changes clearly and use examples if possible
10+
11+
Issue: Please provide reference link to the Github issue
12+
13+
## Tasks
14+
- [ ] Required tests have been written
15+
- [ ] Documentation has been updated
16+
- [ ] Added an entry to CHANGELOG.md if applicable

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
## {{releaseVersion}} - {{releaseDate}}
44

5+
### Fixed
6+
7+
- Cleanup Swift diagnostics when the source file is moved or deleted ([#1653](https://github.com/swiftlang/vscode-swift/pull/1653))
8+
- Make sure newline starts with /// when splitting doc comment ([#1651](https://github.com/swiftlang/vscode-swift/pull/1651))
9+
- Capture diagnostics with `Swift: Capture Diagnostic Bundle` to a .zip file ([#1656](https://github.com/swiftlang/vscode-swift/pull/1656))
10+
- Prevent continuous "package resolve" cycles ([#1654](https://github.com/swiftlang/vscode-swift/pull/1654))
11+
- Fix error when running `Reset Package Dependencies` command from the Project view ([#1661](https://github.com/swiftlang/vscode-swift/pull/1661))
12+
- Mark tests as skipped when a compilation error preempts a test run ([#1659](https://github.com/swiftlang/vscode-swift/pull/1659))
13+
14+
## 2.6.0 - 2025-06-26
15+
516
### Added
617

718
- Support for [multi-root .code-workspace](https://code.visualstudio.com/docs/editing/workspaces/multi-root-workspaces) workspaces ([#1566](https://github.com/swiftlang/vscode-swift/pull/1566))

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "swift-vscode",
33
"displayName": "Swift",
44
"description": "Swift Language Support for Visual Studio Code.",
5-
"version": "2.6.0",
5+
"version": "2.6.1",
66
"publisher": "swiftlang",
77
"icon": "icon.png",
88
"repository": {
@@ -1712,6 +1712,7 @@
17121712
"contributors": "./scripts/generate_contributors_list.sh"
17131713
},
17141714
"devDependencies": {
1715+
"@types/archiver": "^6.0.3",
17151716
"@types/chai": "^4.3.19",
17161717
"@types/chai-as-promised": "^7.1.8",
17171718
"@types/chai-subset": "^1.3.6",
@@ -1764,6 +1765,7 @@
17641765
},
17651766
"dependencies": {
17661767
"@vscode/codicons": "^0.0.36",
1768+
"archiver": "^7.0.1",
17671769
"fast-glob": "^3.3.3",
17681770
"lcov-parse": "^1.0.0",
17691771
"plist": "^3.1.0",

scripts/package.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ main(async () => {
2626
const rootDirectory = getRootDirectory();
2727
const version = await getExtensionVersion();
2828
const versionString = `${version.major}.${version.minor}.${version.patch}`;
29+
30+
if (process.platform === "win32") {
31+
console.log("Packaging the extension is not supported on Windows.");
32+
return process.exit(0);
33+
}
34+
2935
// Update version in CHANGELOG
3036
await updateChangelog(versionString);
3137
// Use VSCE to package the extension

scripts/test_windows.ps1

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ function Update-SwiftBuildAndPackageArguments {
1616
param (
1717
[string]$jsonFilePath = "./assets/test/.vscode/settings.json",
1818
[string]$codeWorkspaceFilePath = "./assets/test.code-workspace",
19-
[string]$windowsSdkVersion = "10.0.22000.0",
20-
[string]$vcToolsVersion = "14.44.35207"
19+
[string]$windowsSdkVersion = "10.0.22000.0"
2120
)
2221

22+
$vcToolsPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC"
23+
$vcToolsVersions = Get-ChildItem -Directory -Path $vcToolsPath | ForEach-Object { $_.Name }
24+
25+
if ($vcToolsVersions.Count -eq 0) {
26+
Write-Host "No versions found in $vcToolsPath"
27+
exit 1
28+
}
29+
30+
$vcToolsVersion = $vcToolsVersions | Sort-Object -Descending | Select-Object -First 1
31+
Write-Host "Highest Visual C++ Tools version: $vcToolsVersion"
32+
2333
$windowsSdkRoot = "C:\Program Files (x86)\Windows Kits\10\"
2434

2535
try {
@@ -39,7 +49,6 @@ function Update-SwiftBuildAndPackageArguments {
3949
if ($jsonContent.PSObject.Properties['swift.buildArguments']) {
4050
$jsonContent.PSObject.Properties.Remove('swift.buildArguments')
4151
}
42-
4352

4453
$jsonContent | Add-Member -MemberType NoteProperty -Name "swift.buildArguments" -Value @(
4554
"-Xbuild-tools-swiftc", "-windows-sdk-root", "-Xbuild-tools-swiftc", $windowsSdkRoot,
@@ -63,7 +72,6 @@ function Update-SwiftBuildAndPackageArguments {
6372
"-Xswiftc", "-visualc-tools-version", "-Xswiftc", $vcToolsVersion
6473
)
6574

66-
6775
$codeWorkspaceContent.PSObject.Properties.Remove('settings')
6876
$codeWorkspaceContent | Add-Member -MemberType NoteProperty -Name "settings" -Value $jsonContent
6977

@@ -88,6 +96,12 @@ if ($LASTEXITCODE -ne 0) {
8896
Write-Host "Swift version:"
8997
Write-Host "$swiftVersionOutput"
9098

99+
Write-Host "Installed MSVC Versions:"
100+
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC"
101+
102+
Write-Host "Installed Windows SDK Versions:"
103+
dir "C:\Program Files (x86)\Windows Kits\10\Include\"
104+
91105
$versionLine = $swiftVersionOutput[0]
92106
if ($versionLine -match "Swift version (\d+)\.(\d+)") {
93107
Write-Host "Matched Swift version: $($matches[0]), $($matches[1]), $($matches[2])"

src/BackgroundCompilation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import { FolderContext } from "./FolderContext";
1919
import { TaskOperation } from "./tasks/TaskQueue";
2020
// eslint-disable-next-line @typescript-eslint/no-require-imports
2121
import debounce = require("lodash.debounce");
22+
import { validFileTypes } from "./utilities/filesystem";
2223

2324
export class BackgroundCompilation implements vscode.Disposable {
2425
private workspaceFileWatcher?: vscode.FileSystemWatcher;
2526
private configurationEventDisposable?: vscode.Disposable;
26-
private validFileTypes = ["swift", "c", "cpp", "h", "hpp", "m", "mm"];
2727
private disposables: vscode.Disposable[] = [];
2828

2929
constructor(private folderContext: FolderContext) {
@@ -44,7 +44,7 @@ export class BackgroundCompilation implements vscode.Disposable {
4444
}
4545

4646
private setupFileWatching() {
47-
const fileTypes = this.validFileTypes.join(",");
47+
const fileTypes = validFileTypes.join(",");
4848
const rootFolders = ["Sources", "Tests", "Snippets", "Plugins"].join(",");
4949
this.disposables.push(
5050
(this.workspaceFileWatcher = vscode.workspace.createFileSystemWatcher(

src/DiagnosticsManager.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import configuration from "./configuration";
2121
import { SwiftExecution } from "./tasks/SwiftExecution";
2222
import { WorkspaceContext } from "./WorkspaceContext";
2323
import { checkIfBuildComplete, lineBreakRegex } from "./utilities/tasks";
24+
import { validFileTypes } from "./utilities/filesystem";
2425

2526
interface ParsedDiagnostic {
2627
uri: string;
@@ -102,6 +103,17 @@ export class DiagnosticsManager implements vscode.Disposable {
102103
context.outputChannel.log(`${e}`, 'Failed to provide "swiftc" diagnostics')
103104
);
104105
});
106+
const fileTypes = validFileTypes.join(",");
107+
this.workspaceFileWatcher = vscode.workspace.createFileSystemWatcher(
108+
`**/*.{${fileTypes}}`,
109+
true,
110+
true
111+
);
112+
this.onDidDeleteDisposible = this.workspaceFileWatcher.onDidDelete(uri => {
113+
if (this.allDiagnostics.delete(uri.fsPath)) {
114+
this.diagnosticCollection.delete(uri);
115+
}
116+
});
105117
}
106118

107119
/**
@@ -276,6 +288,8 @@ export class DiagnosticsManager implements vscode.Disposable {
276288
this.diagnosticCollection.dispose();
277289
this.onDidStartTaskDisposible.dispose();
278290
this.onDidChangeConfigurationDisposible.dispose();
291+
this.onDidDeleteDisposible.dispose();
292+
this.workspaceFileWatcher.dispose();
279293
}
280294

281295
private includeSwiftcDiagnostics(): boolean {
@@ -454,4 +468,6 @@ export class DiagnosticsManager implements vscode.Disposable {
454468

455469
private onDidStartTaskDisposible: vscode.Disposable;
456470
private onDidChangeConfigurationDisposible: vscode.Disposable;
471+
private onDidDeleteDisposible: vscode.Disposable;
472+
private workspaceFileWatcher: vscode.FileSystemWatcher;
457473
}

src/PackageWatcher.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { showReloadExtensionNotification } from "./ui/ReloadExtension";
3030
*/
3131
export class PackageWatcher {
3232
private packageFileWatcher?: vscode.FileSystemWatcher;
33+
private resolvedChangedDisposable?: vscode.Disposable;
3334
private resolvedFileWatcher?: vscode.FileSystemWatcher;
3435
private workspaceStateFileWatcher?: vscode.FileSystemWatcher;
3536
private snippetWatcher?: vscode.FileSystemWatcher;
@@ -59,6 +60,7 @@ export class PackageWatcher {
5960
*/
6061
dispose() {
6162
this.packageFileWatcher?.dispose();
63+
this.resolvedChangedDisposable?.dispose();
6264
this.resolvedFileWatcher?.dispose();
6365
this.workspaceStateFileWatcher?.dispose();
6466
this.snippetWatcher?.dispose();
@@ -77,11 +79,18 @@ export class PackageWatcher {
7779

7880
private createResolvedFileWatcher(): vscode.FileSystemWatcher {
7981
const watcher = vscode.workspace.createFileSystemWatcher(
80-
new vscode.RelativePattern(this.folderContext.folder, "Package.resolved")
82+
new vscode.RelativePattern(this.folderContext.folder, "Package.resolved"),
83+
// https://github.com/swiftlang/vscode-swift/issues/1571
84+
// We can ignore create because that would be seemingly from a Package.resolved
85+
// and will ignore delete as we don't know the reason behind. By still listening
86+
// for change
87+
true,
88+
false,
89+
true
90+
);
91+
this.resolvedChangedDisposable = watcher.onDidChange(
92+
async () => await this.handlePackageResolvedChange()
8193
);
82-
watcher.onDidCreate(async () => await this.handlePackageResolvedChange());
83-
watcher.onDidChange(async () => await this.handlePackageResolvedChange());
84-
watcher.onDidDelete(async () => await this.handlePackageResolvedChange());
8594
return watcher;
8695
}
8796

src/TestExplorer/TestRunner.ts

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import * as stream from "stream";
1818
import * as os from "os";
1919
import * as asyncfs from "fs/promises";
2020
import { FolderContext } from "../FolderContext";
21-
import { compactMap, execFile, getErrorDescription } from "../utilities/utilities";
21+
import {
22+
compactMap,
23+
execFile,
24+
getErrorDescription,
25+
IS_PRODUCTION_BUILD,
26+
} from "../utilities/utilities";
2227
import { createSwiftTask } from "../tasks/SwiftTaskProvider";
2328
import configuration from "../configuration";
2429
import { WorkspaceContext } from "../WorkspaceContext";
@@ -67,6 +72,7 @@ export interface TestRunState {
6772
passed: vscode.TestItem[];
6873
skipped: vscode.TestItem[];
6974
errored: vscode.TestItem[];
75+
enqueued: vscode.TestItem[];
7076
unknown: number;
7177
output: string[];
7278
}
@@ -95,6 +101,7 @@ export class TestRunProxy {
95101
passed: [],
96102
skipped: [],
97103
errored: [],
104+
enqueued: [],
98105
unknown: 0,
99106
output: [],
100107
};
@@ -181,10 +188,9 @@ export class TestRunProxy {
181188
for (const outputLine of this.queuedOutput) {
182189
this.performAppendOutput(this.testRun, outputLine);
183190
}
184-
this.queuedOutput = [];
185191

186192
for (const test of this.testItems) {
187-
this.testRun.enqueued(test);
193+
this.enqueued(test);
188194
}
189195
};
190196

@@ -218,11 +224,17 @@ export class TestRunProxy {
218224
}
219225
}
220226

227+
private enqueued(test: vscode.TestItem) {
228+
this.testRun?.enqueued(test);
229+
this.runState.enqueued.push(test);
230+
}
231+
221232
public unknownTestRan() {
222233
this.runState.unknown++;
223234
}
224235

225236
public started(test: vscode.TestItem) {
237+
this.clearEnqueuedTest(test);
226238
this.runState.pending.push(test);
227239
this.testRun?.started(test);
228240
}
@@ -231,7 +243,29 @@ export class TestRunProxy {
231243
this.runState.pending = this.runState.pending.filter(t => t !== test);
232244
}
233245

246+
private clearEnqueuedTest(test: vscode.TestItem) {
247+
if (IS_PRODUCTION_BUILD) {
248+
// `runState.enqueued` exists only for test validation purposes.
249+
return;
250+
}
251+
252+
this.runState.enqueued = this.runState.enqueued.filter(t => t !== test);
253+
254+
if (!test.parent) {
255+
return;
256+
}
257+
258+
const parentHasEnqueuedChildren = Array.from(test.parent.children).some(([_, child]) =>
259+
this.runState.enqueued.includes(child)
260+
);
261+
262+
if (!parentHasEnqueuedChildren) {
263+
this.clearEnqueuedTest(test.parent);
264+
}
265+
}
266+
234267
public skipped(test: vscode.TestItem) {
268+
this.clearEnqueuedTest(test);
235269
test.tags = [...test.tags, new vscode.TestTag(TestRunProxy.Tags.SKIPPED)];
236270

237271
this.runState.skipped.push(test);
@@ -240,6 +274,7 @@ export class TestRunProxy {
240274
}
241275

242276
public passed(test: vscode.TestItem, duration?: number) {
277+
this.clearEnqueuedTest(test);
243278
this.runState.passed.push(test);
244279
this.clearPendingTest(test);
245280
this.testRun?.passed(test, duration);
@@ -250,6 +285,7 @@ export class TestRunProxy {
250285
message: vscode.TestMessage | readonly vscode.TestMessage[],
251286
duration?: number
252287
) {
288+
this.clearEnqueuedTest(test);
253289
this.runState.failed.push({ test, message });
254290
this.clearPendingTest(test);
255291
this.testRun?.failed(test, message, duration);
@@ -260,6 +296,7 @@ export class TestRunProxy {
260296
message: vscode.TestMessage | readonly vscode.TestMessage[],
261297
duration?: number
262298
) {
299+
this.clearEnqueuedTest(test);
263300
this.runState.errored.push(test);
264301
this.clearPendingTest(test);
265302
this.testRun?.errored(test, message, duration);
@@ -278,6 +315,21 @@ export class TestRunProxy {
278315
this.failed(test, new vscode.TestMessage("Test did not complete."));
279316
});
280317

318+
// If there are tests that never started, mark them as skipped.
319+
// This can happen if there is a build error preventing tests from running.
320+
this.runState.enqueued.forEach(test => {
321+
// Omit adding the root test item as a skipped test to keep just the suites/tests
322+
// in the test run output, just like a regular pass/fail test run.
323+
if (test.parent) {
324+
for (const output of this.queuedOutput) {
325+
this.appendOutputToTest(output, test);
326+
}
327+
this.skipped(test);
328+
}
329+
});
330+
331+
this.queuedOutput = [];
332+
281333
this.reportAttachments();
282334
this.testRun?.end();
283335
this.testRunCompleteEmitter.fire();

0 commit comments

Comments
 (0)