Skip to content
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: 5 additions & 1 deletion src/WorkspaceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,11 @@ export class WorkspaceContext implements ExternalWorkspaceContext, vscode.Dispos
const observersReversed = [...this.observers];
observersReversed.reverse();
for (const observer of observersReversed) {
await observer({ folder, operation: FolderOperation.remove, workspace: this });
try {
await observer({ folder, operation: FolderOperation.remove, workspace: this });
} catch (error) {
this.logger.error(`Failed to remove folder ${folder.name}: ${error}`);
}
}
folder.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,11 @@ tag("large").suite("Test Explorer Suite", function () {
issues: [
`2 \u{203A} ${MessageRenderer.render({
symbol: TestSymbol.fail,
text: "Expectation failed: (arg → 2) != 2",
text: folderContext.toolchain.swiftVersion.isGreaterThanOrEqual(
new Version(6, 4, 0)
)
? "Expectation failed: arg != 2"
: "Expectation failed: (arg → 2) != 2",
})}`,
],
test: failedId,
Expand Down
14 changes: 11 additions & 3 deletions test/integration-tests/testexplorer/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,23 @@ export function assertTestResults(
unknown?: number;
}
) {
function firstLine(str: string) {
const stripped = stripAnsi(str);
const endOfLine = stripped.indexOf("\n");
if (endOfLine > 0) {
return stripped.slice(0, endOfLine);
}
return str;
}
assert.deepEqual(
{
passed: testRun.runState.passed.map(({ id }) => id).sort((a, b) => a.localeCompare(b)),
failed: testRun.runState.failed
.map(({ test, message }) => ({
test: test.id,
issues: Array.isArray(message)
? message.map(({ message }) => stripAnsi(message.toString()))
: [stripAnsi((message as vscode.TestMessage).message.toString())],
? message.map(({ message }) => firstLine(message.toString()))
: [firstLine((message as vscode.TestMessage).message.toString())],
}))
.sort((a, b) => a.test.localeCompare(b.test)),
skipped: testRun.runState.skipped
Expand All @@ -141,7 +149,7 @@ export function assertTestResults(
failed: (state.failed ?? [])
.map(({ test, issues }) => ({
test,
issues: issues.map(message => stripAnsi(message)),
issues: issues.map(message => firstLine(message)),
}))
.sort((a, b) => a.test.localeCompare(b.test)),
skipped: (state.skipped ?? []).sort((a, b) => a.localeCompare(b)),
Expand Down
24 changes: 21 additions & 3 deletions test/integration-tests/utilities/testutilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class ExtensionActivationLogger implements Loggable {
}

info(message: string) {
const timestamp = this.formatTimestamp();
const timestampedMessage = `[${timestamp}] ${message}`;
const timestampedMessage = this.timestampedMessage(message);

if (this.logger) {
this.logger.info(timestampedMessage);
Expand All @@ -83,10 +82,25 @@ class ExtensionActivationLogger implements Loggable {
}
}

error(message: string) {
const timestampedMessage = this.timestampedMessage(message);

if (this.logger) {
this.logger.error(timestampedMessage);
} else {
this._logs.push(timestampedMessage);
}
}

reset() {
this._logs = [];
this.logger = undefined;
}

private timestampedMessage(message: string): string {
const timestamp = this.formatTimestamp();
return `[${timestamp}] ${message}`;
}
}

// Mocha doesn't give us a hook to run code when a before block times out.
Expand Down Expand Up @@ -426,7 +440,11 @@ const extensionBootstrapper = (() => {
) ?? Promise.resolve()
);
activationLogger.info(`Running extension deactivation function.`);
await activatedAPI.deactivate();
try {
await activatedAPI.deactivate();
} catch (error) {
activationLogger.error(`Failed to deactivate extension: ${error}`);
}
activationLogger.reset();
activatedAPI = undefined;
lastTestName = undefined;
Expand Down
Loading