Skip to content

Commit 6214ff9

Browse files
committed
Extra debug logging
1 parent 5f3a89a commit 6214ff9

13 files changed

+171
-93
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
. .github/workflows/scripts/setup-linux.sh
2424
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
2525
npm ci
26-
npm run compile
2726
npm run package
2827
npm run preview-package
2928
for file in *.vsix; do
@@ -47,9 +46,7 @@ jobs:
4746
tests:
4847
name: ${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && 'Full Test Run' || 'Test'}}
4948
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
50-
needs: package
5149
with:
52-
needs_token: true
5350
# Linux
5451
linux_exclude_swift_versions: '[{"swift_version": "nightly-6.1"},{"swift_version": "nightly-main"}]'
5552
linux_env_vars: |
@@ -64,6 +61,7 @@ jobs:
6461
windows_exclude_swift_versions: '[{"swift_version": "nightly-6.1"},{"swift_version": "nightly"}]'
6562
windows_env_vars: |
6663
CI=1
64+
VSCODE_DEBUG=1
6765
FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}}
6866
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
6967
windows_build_command: scripts\test_windows.ps1

.vscode-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ module.exports = defineConfig({
8585
},
8686
},
8787
},
88+
env: {
89+
VSCODE_SWIFT_TEST: 1,
90+
},
8891
reuseMachineInstall: !isCIBuild,
8992
installExtensions,
9093
},

assets/test/.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
"-DTEST_ARGUMENT_SET_VIA_TEST_BUILD_ARGUMENTS_SETTING"
99
],
1010
"lldb.verboseLogging": true,
11-
"swift.backgroundCompilation": false,
1211
"swift.sourcekit-lsp.backgroundIndexing": "off"
1312
}

test/integration-tests/DiagnosticsManager.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,15 @@ suite("DiagnosticsManager Test Suite", function () {
244244
workspaceContext.focusFolder(null);
245245

246246
resetSettings = await updateSettings({ "swift.diagnosticsStyle": style });
247-
const task = await createBuildAllTask(folderContext);
248-
// This return exit code and output for the task but we will omit it here
249-
// because the failures are expected and we just want the task to build
250-
await executeTaskAndWaitForResult(task).catch(() => {
251-
/* Ignore */
252-
});
253247
});
254248

255249
test("succeeds", async function () {
256250
await Promise.all([
257251
waitForDiagnostics(expected()),
258252
createBuildAllTask(folderContext).then(task =>
259-
executeTaskAndWaitForResult(task)
253+
executeTaskAndWaitForResult(task).catch(() => {
254+
/* Ignore */
255+
})
260256
),
261257
]);
262258
await waitForNoRunningTasks();

test/integration-tests/SwiftSnippet.test.ts

Lines changed: 50 additions & 24 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>) | undefined;
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+
await workspaceContext.focusFolder(folder);
59+
await vscode.window.showTextDocument(uri);
6160

6261
// Set a breakpoint
6362
vscode.debug.addBreakpoints(breakpoints);
@@ -66,19 +65,24 @@ suite("SwiftSnippet Test Suite @slow", function () {
6665
});
6766

6867
suiteTeardown(async () => {
69-
closeAllEditors();
68+
await closeAllEditors();
7069
vscode.debug.removeBreakpoints(breakpoints);
70+
if (resetSettings) {
71+
await resetSettings();
72+
}
7173
});
7274

7375
test("Run `Swift: Run Swift Snippet` command for snippet file", async () => {
7476
const sessionPromise = waitUntilDebugSessionTerminates("Run hello");
7577

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

7880
expect(succeeded).to.be.true;
7981
const session = await sessionPromise;
80-
expect(normalizePath(session.configuration.program)).to.equal(
81-
normalizePath(testAssetPath("defaultPackage"), ".build", "debug", "hello")
82+
expect(vscode.Uri.file(session.configuration.program).fsPath).to.equal(
83+
testAssetUri(
84+
"defaultPackage/.build/debug/hello" + (process.platform === "win32" ? ".exe" : "")
85+
).fsPath
8286
);
8387
expect(session.configuration).to.have.property("noDebug", true);
8488
});
@@ -91,16 +95,38 @@ suite("SwiftSnippet Test Suite @slow", function () {
9195
);
9296
const sessionPromise = waitUntilDebugSessionTerminates("Run hello");
9397

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

96106
// Once bp is hit, continue
97-
await bpPromise.then(() => continueSession());
107+
await bpPromise;
108+
console.log("here 3");
109+
let succeeded = false;
110+
succeededPromise.then(s => (succeeded = s));
111+
while (!succeeded) {
112+
console.log("here continue");
113+
try {
114+
await continueSession();
115+
} catch {
116+
// Ignore
117+
}
118+
console.log("here continued");
119+
await new Promise(r => setTimeout(r, 500));
120+
}
121+
console.log("here 4");
98122

99-
await expect(succeeded).to.eventually.be.true;
123+
expect(succeeded).to.be.true;
100124

101125
const session = await sessionPromise;
102-
expect(normalizePath(session.configuration.program)).to.equal(
103-
normalizePath(testAssetPath("defaultPackage"), ".build", "debug", "hello")
126+
expect(vscode.Uri.file(session.configuration.program).fsPath).to.equal(
127+
testAssetUri(
128+
"defaultPackage/.build/debug/hello" + (process.platform === "win32" ? ".exe" : "")
129+
).fsPath
104130
);
105131
expect(session.configuration).to.not.have.property("noDebug");
106132
});

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

Lines changed: 36 additions & 32 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,52 +41,35 @@ 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
}
48+
// A breakpoint will have not effect on the Run command.
49+
vscode.debug.addBreakpoints(breakpoints);
4950

5051
workspaceContext = ctx;
5152
await waitForNoRunningTasks();
5253
folderContext = await folderInRootWorkspace("defaultPackage", workspaceContext);
5354
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);
55+
const tasks = await vscode.tasks.fetchTasks({ type: "swift" });
56+
tasks.forEach(t =>
57+
console.log("Label: " + t.definition.label + " => " + JSON.stringify(t.definition))
58+
);
5959
},
6060
requiresDebugger: true,
6161
});
6262

63-
test("Swift: Run Build", async () => {
64-
// A breakpoint will have not effect on the Run command.
65-
vscode.debug.addBreakpoints(breakpoints);
66-
67-
const result = await vscode.commands.executeCommand(Commands.RUN);
68-
expect(result).to.be.true;
69-
63+
suiteTeardown(async () => {
7064
vscode.debug.removeBreakpoints(breakpoints);
7165
});
7266

73-
test("Swift: Clean Build", async () => {
74-
let result = await vscode.commands.executeCommand(Commands.RUN);
75-
expect(result).to.be.true;
76-
77-
const buildPath = path.join(folderContext.folder.fsPath, ".build");
78-
const beforeItemCount = (await fs.readdir(buildPath)).length;
79-
80-
result = await vscode.commands.executeCommand(Commands.CLEAN_BUILD);
67+
test("Swift: Run Build", async () => {
68+
const result = await vscode.commands.executeCommand(Commands.RUN, "PackageExe");
8169
expect(result).to.be.true;
82-
83-
const afterItemCount = (await fs.readdir(buildPath)).length;
84-
// .build folder is going to be filled with built artifacts after Commands.RUN command
85-
// After executing the clean command the build directory is guranteed to have less entry.
86-
expect(afterItemCount).to.be.lessThan(beforeItemCount);
8770
});
8871

8972
test("Swift: Debug Build", async () => {
90-
vscode.debug.addBreakpoints(breakpoints);
9173
// Promise used to indicate we hit the break point.
9274
// NB: "stopped" is the exact command when debuggee has stopped due to break point,
9375
// but "stackTrace" is the deterministic sync point we will use to make sure we can execute continue
@@ -97,12 +79,34 @@ suite("Build Commands @slow", function () {
9779
"stackTrace"
9880
);
9981

100-
const result = vscode.commands.executeCommand(Commands.DEBUG);
101-
expect(result).to.eventually.be.true;
82+
const resultPromise: Thenable<boolean> = vscode.commands.executeCommand(
83+
Commands.DEBUG,
84+
"PackageExe"
85+
);
10286

10387
await bpPromise;
104-
await continueSession();
88+
let succeeded = false;
89+
resultPromise.then(s => (succeeded = s));
90+
while (!succeeded) {
91+
await continueSession();
92+
await new Promise(r => setTimeout(r, 500));
93+
}
94+
await expect(resultPromise).to.eventually.be.true;
95+
});
10596

106-
vscode.debug.removeBreakpoints(breakpoints);
97+
test("Swift: Clean Build", async () => {
98+
let result = await vscode.commands.executeCommand(Commands.RUN, "PackageExe");
99+
expect(result).to.be.true;
100+
101+
const buildPath = path.join(folderContext.folder.fsPath, ".build");
102+
const beforeItemCount = (await fs.readdir(buildPath)).length;
103+
104+
result = await vscode.commands.executeCommand(Commands.CLEAN_BUILD);
105+
expect(result).to.be.true;
106+
107+
const afterItemCount = (await fs.readdir(buildPath)).length;
108+
// .build folder is going to be filled with built artifacts after Commands.RUN command
109+
// After executing the clean command the build directory is guranteed to have less entry.
110+
expect(afterItemCount).to.be.lessThan(beforeItemCount);
107111
});
108112
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { WorkspaceContext } from "../../../src/WorkspaceContext";
2121
import { Commands } from "../../../src/commands";
2222
import { activateExtensionForSuite, folderInRootWorkspace } from "../utilities/testutilities";
2323
import { executeTaskAndWaitForResult, waitForNoRunningTasks } from "../../utilities/tasks";
24-
import { getBuildAllTask, SwiftTask } from "../../../src/tasks/SwiftTaskProvider";
24+
import { createBuildAllTask } from "../../../src/tasks/SwiftTaskProvider";
2525

2626
suite("Dependency Commmands Test Suite", function () {
2727
// full workflow's interaction with spm is longer than the default timeout
@@ -58,7 +58,7 @@ suite("Dependency Commmands Test Suite", function () {
5858

5959
setup(async () => {
6060
await workspaceContext.focusFolder(depsContext);
61-
await executeTaskAndWaitForResult((await getBuildAllTask(depsContext)) as SwiftTask);
61+
await executeTaskAndWaitForResult(await createBuildAllTask(depsContext));
6262
treeProvider = new ProjectPanelProvider(workspaceContext);
6363
});
6464

test/integration-tests/language/LanguageClientIntegration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ import { LanguageClientManager } from "../../../src/sourcekit-lsp/LanguageClient
1919
import { WorkspaceContext } from "../../../src/WorkspaceContext";
2020
import { testAssetUri } from "../../fixtures";
2121
import { executeTaskAndWaitForResult, waitForNoRunningTasks } from "../../utilities/tasks";
22-
import { getBuildAllTask, SwiftTask } from "../../../src/tasks/SwiftTaskProvider";
22+
import { createBuildAllTask } from "../../../src/tasks/SwiftTaskProvider";
2323
import { activateExtensionForSuite, folderInRootWorkspace } from "../utilities/testutilities";
2424
import { waitForClientState, waitForIndex } from "../utilities/lsputilities";
2525
import { FolderContext } from "../../../src/FolderContext";
2626

2727
async function buildProject(ctx: WorkspaceContext, name: string) {
2828
await waitForNoRunningTasks();
2929
const folderContext = await folderInRootWorkspace(name, ctx);
30-
const task = (await getBuildAllTask(folderContext)) as SwiftTask;
30+
const task = await createBuildAllTask(folderContext);
3131
const { exitCode, output } = await executeTaskAndWaitForResult(task);
3232
expect(exitCode, `${output}`).to.equal(0);
3333
return folderContext;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
cleanOutput,
2929
executeTaskAndWaitForResult,
3030
waitForEndTaskProcess,
31+
waitForNoRunningTasks,
3132
} from "../../utilities/tasks";
3233
import { mutable } from "../../utilities/types";
3334
import { SwiftExecution } from "../../../src/tasks/SwiftExecution";
@@ -198,11 +199,13 @@ suite("SwiftPluginTaskProvider Test Suite", function () {
198199
suite("createSwiftPluginTask", () => {
199200
let taskProvider: SwiftPluginTaskProvider;
200201

201-
setup(() => {
202+
setup(async () => {
202203
taskProvider = workspaceContext.pluginProvider;
204+
await waitForNoRunningTasks();
203205
});
204206

205207
test("Exit code on success", async () => {
208+
console.log("Plugin: " + JSON.stringify(folderContext.swiftPackage.plugins[0]));
206209
const task = taskProvider.createSwiftPluginTask(
207210
folderContext.swiftPackage.plugins[0],
208211
folderContext.toolchain,
@@ -212,7 +215,7 @@ suite("SwiftPluginTaskProvider Test Suite", function () {
212215
}
213216
);
214217
const { exitCode, output } = await executeTaskAndWaitForResult(task);
215-
expect(exitCode).to.equal(0);
218+
expect(exitCode, output).to.equal(0);
216219
expect(cleanOutput(output)).to.include("Hello, World!");
217220
});
218221

0 commit comments

Comments
 (0)