Skip to content

Run windows tests directly in same shell #1487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/test_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ npm ci -ignore-script node-pty
npm run lint
npm run format
npm run package
$Process = Start-Process npm "run integration-test" -Wait -PassThru -NoNewWindow
if ($Process.ExitCode -eq 0) {
npm run integration-test
if ($LASTEXITCODE -eq 0) {
Write-Host 'SUCCESS'
} else {
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
Write-Host ('FAILED ({0})' -f $LASTEXITCODE)
exit 1
}
24 changes: 16 additions & 8 deletions test/integration-tests/utilities/testutilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { waitForNoRunningTasks } from "../../utilities/tasks";
import { closeAllEditors } from "../../utilities/commands";
import { isDeepStrictEqual } from "util";
import { Version } from "../../../src/utilities/version";
import { SwiftOutputChannel } from "../../../src/ui/SwiftOutputChannel";
import configuration from "../../../src/configuration";

function getRootWorkspaceFolder(): vscode.WorkspaceFolder {
Expand All @@ -31,6 +32,12 @@ function getRootWorkspaceFolder(): vscode.WorkspaceFolder {
return result;
}

function printLogs(outputChannel: SwiftOutputChannel, message: string) {
console.error(`${message}, captured logs are:`);
outputChannel.logs.map(log => console.log(log));
console.log("======== END OF LOGS ========\n\n");
}

const extensionBootstrapper = (() => {
let activator: (() => Promise<Api>) | undefined = undefined;
let activatedAPI: Api | undefined = undefined;
Expand Down Expand Up @@ -116,11 +123,10 @@ const extensionBootstrapper = (() => {

mocha.afterEach(function () {
if (this.currentTest && activatedAPI && this.currentTest.isFailed()) {
console.log(`Captured logs during ${testTitle(this.currentTest)}:`);
for (const log of activatedAPI.outputChannel.logs) {
console.log(log);
}
console.log("======== END OF LOGS ========\n\n");
printLogs(
activatedAPI.outputChannel,
`Test failed: ${testTitle(this.currentTest)}`
);
}
});

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

if (!workspaceContext) {
printLogs(
activatedAPI.outputChannel,
"Error during test/suite setup, workspace context could not be created"
);
throw new Error("Extension did not activate. Workspace context is not available.");
}

Expand Down