Skip to content

Commit 9b3b500

Browse files
committed
Run windows tests directly in same shell
Occasionally the Windows tests will hang after all tests have completed until the GitHub action times out. Using `Start-Process` with the `-Wait` flag will wait for the process and all of its child processes to terminate. This means that if the VS Code instance under test has any lingering processes the build may hang forever. Instead run the test command directly, referencing the success status with `$LASTEXITCODE`. This should hopefully report the status more reliably without hanging.
1 parent a09143c commit 9b3b500

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Diff for: scripts/test_windows.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ npm ci -ignore-script node-pty
6464
npm run lint
6565
npm run format
6666
npm run package
67-
$Process = Start-Process npm "run integration-test" -Wait -PassThru -NoNewWindow
68-
if ($Process.ExitCode -eq 0) {
67+
npm run integration-test
68+
if ($LASTEXITCODE -eq 0) {
6969
Write-Host 'SUCCESS'
7070
} else {
71-
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
71+
Write-Host ('FAILED ({0})' -f $LASTEXITCODE)
7272
exit 1
7373
}

Diff for: test/integration-tests/utilities/testutilities.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { waitForNoRunningTasks } from "../../utilities/tasks";
2323
import { closeAllEditors } from "../../utilities/commands";
2424
import { isDeepStrictEqual } from "util";
2525
import { Version } from "../../../src/utilities/version";
26+
import { SwiftOutputChannel } from "../../../src/ui/SwiftOutputChannel";
2627
import configuration from "../../../src/configuration";
2728

2829
function getRootWorkspaceFolder(): vscode.WorkspaceFolder {
@@ -31,6 +32,12 @@ function getRootWorkspaceFolder(): vscode.WorkspaceFolder {
3132
return result;
3233
}
3334

35+
function printLogs(outputChannel: SwiftOutputChannel, message: string) {
36+
console.error(`${message}, captured logs are:`);
37+
outputChannel.logs.map(log => console.log(log));
38+
console.log("======== END OF LOGS ========\n\n");
39+
}
40+
3441
const extensionBootstrapper = (() => {
3542
let activator: (() => Promise<Api>) | undefined = undefined;
3643
let activatedAPI: Api | undefined = undefined;
@@ -116,11 +123,10 @@ const extensionBootstrapper = (() => {
116123

117124
mocha.afterEach(function () {
118125
if (this.currentTest && activatedAPI && this.currentTest.isFailed()) {
119-
console.log(`Captured logs during ${testTitle(this.currentTest)}:`);
120-
for (const log of activatedAPI.outputChannel.logs) {
121-
console.log(log);
122-
}
123-
console.log("======== END OF LOGS ========\n\n");
126+
printLogs(
127+
activatedAPI.outputChannel,
128+
`Test failed: ${testTitle(this.currentTest)}`
129+
);
124130
}
125131
});
126132

@@ -136,9 +142,7 @@ const extensionBootstrapper = (() => {
136142
}
137143
} catch (error) {
138144
if (workspaceContext) {
139-
console.error(`Error during test/suite teardown, captured logs are:`);
140-
workspaceContext.outputChannel.logs.map(log => console.log(log));
141-
console.log("======== END OF LOGS ========\n\n");
145+
printLogs(workspaceContext.outputChannel, "Error during test/suite teardown");
142146
}
143147
// We always want to restore settings and deactivate the extension even if the
144148
// user supplied teardown fails. That way we have the best chance at not causing
@@ -197,6 +201,10 @@ const extensionBootstrapper = (() => {
197201
}
198202

199203
if (!workspaceContext) {
204+
printLogs(
205+
activatedAPI.outputChannel,
206+
"Error during test/suite setup, workspace context could not be created"
207+
);
200208
throw new Error("Extension did not activate. Workspace context is not available.");
201209
}
202210

0 commit comments

Comments
 (0)