Skip to content

Commit 6eeb11f

Browse files
committed
Extra debug logging
1 parent 5f3a89a commit 6eeb11f

File tree

7 files changed

+69
-36
lines changed

7 files changed

+69
-36
lines changed

.github/workflows/pull_request.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
name: ${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && 'Full Test Run' || 'Test'}}
4949
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
5050
needs: package
51+
if: always()
5152
with:
5253
needs_token: true
5354
# Linux
@@ -58,13 +59,19 @@ jobs:
5859
NVM_DIR=/usr/local/nvm
5960
CI=1
6061
FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}}
62+
VSCODE_SWIFT_VSIX_ID=${{ contains(github.event.pull_request.labels.*.name, 'vsix-test-run') && needs.package.outputs.artifact-id || ''}}
63+
GITHUB_REPOSITORY=${{github.repository}}
6164
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
6265
linux_build_command: ./scripts/test.sh
6366
# Windows
6467
windows_exclude_swift_versions: '[{"swift_version": "nightly-6.1"},{"swift_version": "nightly"}]'
6568
windows_env_vars: |
6669
CI=1
70+
VSCODE_DEBUG=1
6771
FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}}
72+
VSCODE_SWIFT_VSIX_ID=${{ contains(github.event.pull_request.labels.*.name, 'vsix-test-run') && needs.package.outputs.artifact-id || ''}}
73+
VSCODE_SWIFT_VSIX=vscode-swift.vsix
74+
GITHUB_REPOSITORY=${{github.repository}}
6875
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
6976
windows_build_command: scripts\test_windows.ps1
7077
enable_windows_docker: false

assets/test/command-plugin/Plugins/command-plugin/command-plugin.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import PackagePlugin
44
struct command_plugin: CommandPlugin {
55
// Entry point for command plugins applied to Swift Packages.
66
func performCommand(context: PluginContext, arguments: [String]) async throws {
7+
try await Task.sleep(for: .seconds(1))
78
print("Hello, World!")
89
}
910
}

test/integration-tests/SwiftSnippet.test.ts

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import * as vscode from "vscode";
16-
import { testAssetPath, testAssetUri } from "../fixtures";
16+
import { testAssetUri } from "../fixtures";
1717
import { waitForNoRunningTasks } from "../utilities/tasks";
1818
import { expect } from "chai";
1919
import {
@@ -22,19 +22,14 @@ import {
2222
waitUntilDebugSessionTerminates,
2323
} from "../utilities/debug";
2424
import { Version } from "../../src/utilities/version";
25-
import { activateExtensionForSuite, folderInRootWorkspace } from "./utilities/testutilities";
25+
import {
26+
activateExtensionForSuite,
27+
folderInRootWorkspace,
28+
updateSettings,
29+
} from "./utilities/testutilities";
2630
import { WorkspaceContext } from "../../src/WorkspaceContext";
27-
import { join } from "path";
2831
import { closeAllEditors } from "../utilities/commands";
29-
30-
function normalizePath(...segments: string[]): string {
31-
let path = join(...segments);
32-
if (process.platform === "win32") {
33-
path = path.endsWith(".exe") ? path : path + ".exe";
34-
path = path.replace(/\//g, "\\");
35-
}
36-
return path.toLocaleLowerCase(); // Windows may use d:\ or D:\
37-
}
32+
import { Commands } from "../../src/commands";
3833

3934
suite("SwiftSnippet Test Suite @slow", function () {
4035
this.timeout(180000);
@@ -44,20 +39,24 @@ suite("SwiftSnippet Test Suite @slow", function () {
4439
new vscode.SourceBreakpoint(new vscode.Location(uri, new vscode.Position(2, 0))),
4540
];
4641
let workspaceContext: WorkspaceContext;
42+
let resetSettings: () => Promise<void>;
4743

4844
activateExtensionForSuite({
4945
async setup(ctx) {
5046
workspaceContext = ctx;
5147

5248
const folder = await folderInRootWorkspace("defaultPackage", workspaceContext);
53-
if (folder.toolchain.swiftVersion.isLessThan(new Version(5, 9, 0))) {
49+
if (folder.toolchain.swiftVersion.isLessThan(new Version(5, 10, 0))) {
5450
this.skip();
5551
}
52+
resetSettings = await updateSettings({
53+
"swift.debugger.debugAdapter": "lldb-dap",
54+
});
5655
await waitForNoRunningTasks();
5756

5857
// File needs to be open for command to be enabled
59-
const doc = await vscode.workspace.openTextDocument(uri.fsPath);
60-
await vscode.window.showTextDocument(doc);
58+
workspaceContext.focusFolder(folder);
59+
await vscode.window.showTextDocument(uri);
6160

6261
// Set a breakpoint
6362
vscode.debug.addBreakpoints(breakpoints);
@@ -68,17 +67,20 @@ suite("SwiftSnippet Test Suite @slow", function () {
6867
suiteTeardown(async () => {
6968
closeAllEditors();
7069
vscode.debug.removeBreakpoints(breakpoints);
70+
await resetSettings();
7171
});
7272

7373
test("Run `Swift: Run Swift Snippet` command for snippet file", async () => {
7474
const sessionPromise = waitUntilDebugSessionTerminates("Run hello");
7575

76-
const succeeded = await vscode.commands.executeCommand("swift.runSnippet");
76+
const succeeded = await vscode.commands.executeCommand(Commands.RUN_SNIPPET, "hello");
7777

7878
expect(succeeded).to.be.true;
7979
const session = await sessionPromise;
80-
expect(normalizePath(session.configuration.program)).to.equal(
81-
normalizePath(testAssetPath("defaultPackage"), ".build", "debug", "hello")
80+
expect(vscode.Uri.file(session.configuration.program).fsPath).to.equal(
81+
testAssetUri(
82+
"defaultPackage/.build/debug/hello" + (process.platform === "win32" ? ".exe" : "")
83+
).fsPath
8284
);
8385
expect(session.configuration).to.have.property("noDebug", true);
8486
});
@@ -91,16 +93,34 @@ suite("SwiftSnippet Test Suite @slow", function () {
9193
);
9294
const sessionPromise = waitUntilDebugSessionTerminates("Run hello");
9395

94-
const succeeded = vscode.commands.executeCommand("swift.debugSnippet");
96+
console.log("here 1");
97+
const succeededPromise: Thenable<boolean> = vscode.commands.executeCommand(
98+
Commands.DEBUG_SNIPPET,
99+
"hello"
100+
);
101+
102+
console.log("here 2");
95103

96104
// Once bp is hit, continue
97-
await bpPromise.then(() => continueSession());
105+
await bpPromise;
106+
console.log("here 3");
107+
let succeeded = false;
108+
succeededPromise.then(s => (succeeded = s));
109+
while (!succeeded) {
110+
console.log("here continue");
111+
await continueSession();
112+
console.log("here continued");
113+
await new Promise(r => setTimeout(r, 500));
114+
}
115+
console.log("here 4");
98116

99-
await expect(succeeded).to.eventually.be.true;
117+
expect(succeeded).to.be.true;
100118

101119
const session = await sessionPromise;
102-
expect(normalizePath(session.configuration.program)).to.equal(
103-
normalizePath(testAssetPath("defaultPackage"), ".build", "debug", "hello")
120+
expect(vscode.Uri.file(session.configuration.program).fsPath).to.equal(
121+
testAssetUri(
122+
"defaultPackage/.build/debug/hello" + (process.platform === "win32" ? ".exe" : "")
123+
).fsPath
104124
);
105125
expect(session.configuration).to.not.have.property("noDebug");
106126
});

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { testAssetUri } from "../../fixtures";
2121
import { FolderContext } from "../../../src/FolderContext";
2222
import { WorkspaceContext } from "../../../src/WorkspaceContext";
2323
import { Commands } from "../../../src/commands";
24-
import { Workbench } from "../../../src/utilities/commands";
2524
import { continueSession, waitForDebugAdapterRequest } from "../../utilities/debug";
2625
import { activateExtensionForSuite, folderInRootWorkspace } from "../utilities/testutilities";
2726
import { Version } from "../../../src/utilities/version";
@@ -42,7 +41,7 @@ suite("Build Commands @slow", function () {
4241
// The description of this package is crashing on Windows with Swift 5.9.x and below
4342
if (
4443
process.platform === "win32" &&
45-
ctx.globalToolchain.swiftVersion.isLessThanOrEqual(new Version(5, 9, 0))
44+
ctx.globalToolchain.swiftVersion.isLessThan(new Version(5, 10, 0))
4645
) {
4746
this.skip();
4847
}
@@ -51,11 +50,10 @@ suite("Build Commands @slow", function () {
5150
await waitForNoRunningTasks();
5251
folderContext = await folderInRootWorkspace("defaultPackage", workspaceContext);
5352
await workspaceContext.focusFolder(folderContext);
54-
await vscode.tasks.fetchTasks({ type: "swift" });
55-
await vscode.window.showTextDocument(uri);
56-
},
57-
async teardown() {
58-
await vscode.commands.executeCommand(Workbench.ACTION_CLOSEALLEDITORS);
53+
const tasks = await vscode.tasks.fetchTasks({ type: "swift" });
54+
tasks.forEach(t =>
55+
console.log("Label: " + t.definition.label + " => " + JSON.stringify(t.definition))
56+
);
5957
},
6058
requiresDebugger: true,
6159
});
@@ -64,14 +62,14 @@ suite("Build Commands @slow", function () {
6462
// A breakpoint will have not effect on the Run command.
6563
vscode.debug.addBreakpoints(breakpoints);
6664

67-
const result = await vscode.commands.executeCommand(Commands.RUN);
65+
const result = await vscode.commands.executeCommand(Commands.RUN, "PackageExe");
6866
expect(result).to.be.true;
6967

7068
vscode.debug.removeBreakpoints(breakpoints);
7169
});
7270

7371
test("Swift: Clean Build", async () => {
74-
let result = await vscode.commands.executeCommand(Commands.RUN);
72+
let result = await vscode.commands.executeCommand(Commands.RUN, "PackageExe");
7573
expect(result).to.be.true;
7674

7775
const buildPath = path.join(folderContext.folder.fsPath, ".build");
@@ -97,7 +95,7 @@ suite("Build Commands @slow", function () {
9795
"stackTrace"
9896
);
9997

100-
const result = vscode.commands.executeCommand(Commands.DEBUG);
98+
const result = vscode.commands.executeCommand(Commands.DEBUG, "PackageExe");
10199
expect(result).to.eventually.be.true;
102100

103101
await bpPromise;

test/integration-tests/tasks/SwiftPluginTaskProvider.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ suite("SwiftPluginTaskProvider Test Suite", function () {
203203
});
204204

205205
test("Exit code on success", async () => {
206+
console.log("Plugin: " + JSON.stringify(folderContext.swiftPackage.plugins[0]));
206207
const task = taskProvider.createSwiftPluginTask(
207208
folderContext.swiftPackage.plugins[0],
208209
folderContext.toolchain,
@@ -212,7 +213,7 @@ suite("SwiftPluginTaskProvider Test Suite", function () {
212213
}
213214
);
214215
const { exitCode, output } = await executeTaskAndWaitForResult(task);
215-
expect(exitCode).to.equal(0);
216+
expect(exitCode, output).to.equal(0);
216217
expect(cleanOutput(output)).to.include("Hello, World!");
217218
});
218219

test/integration-tests/ui/ProjectPanelProvider.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { WorkspaceContext } from "../../../src/WorkspaceContext";
3535
import { Version } from "../../../src/utilities/version";
3636
import { wait } from "../../../src/utilities/utilities";
3737
import { SwiftOutputChannel } from "../../../src/ui/SwiftOutputChannel";
38+
import { Commands } from "../../../src/commands";
3839

3940
suite("ProjectPanelProvider Test Suite", function () {
4041
let workspaceContext: WorkspaceContext;
@@ -189,7 +190,10 @@ suite("ProjectPanelProvider Test Suite", function () {
189190
return snippet;
190191
}
191192
);
192-
const result = await vscode.commands.executeCommand("swift.runSnippet", snippet?.name);
193+
const result = await vscode.commands.executeCommand(
194+
Commands.RUN_SNIPPET,
195+
snippet?.name
196+
);
193197
expect(result).to.be.true;
194198
});
195199
});

test/utilities/tasks.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ export async function executeTaskAndWaitForResult(
4444
vscode.tasks.onDidStartTask(async ({ execution }) => {
4545
let output = "";
4646
const runningTask = execution.task as SwiftTask;
47+
if (runningTask.detail !== task.detail) {
48+
return;
49+
}
4750
const disposables = [runningTask.execution.onDidWrite(e => (output += e))];
4851
const exitCode = await exitPromise;
4952
await endPromise;
50-
await new Promise(r => setTimeout(r, 500));
5153
disposables.forEach(d => d.dispose());
5254
res({
5355
output,

0 commit comments

Comments
 (0)