mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
eng: make it selfhost failure log easier to access and more stable (#212626)
This commit is contained in:
@@ -55,7 +55,11 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
};
|
||||
|
||||
let startedTrackingFailures = false;
|
||||
guessWorkspaceFolder().then(folder => {
|
||||
if (folder) {
|
||||
context.subscriptions.push(new FailureTracker(context, folder.uri.fsPath));
|
||||
}
|
||||
});
|
||||
|
||||
const createRunHandler = (
|
||||
runnerCtor: { new (folder: vscode.WorkspaceFolder): VSCodeTestRunner },
|
||||
@@ -71,11 +75,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!startedTrackingFailures) {
|
||||
startedTrackingFailures = true;
|
||||
context.subscriptions.push(new FailureTracker(folder.uri.fsPath));
|
||||
}
|
||||
|
||||
const runner = new runnerCtor(folder);
|
||||
const map = await getPendingTestMap(ctrl, req.include ?? gatherTestItems(ctrl.items));
|
||||
const task = ctrl.createTestRun(req);
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { spawn } from 'child_process';
|
||||
import { existsSync, mkdirSync, renameSync } from 'fs';
|
||||
import { readFile, writeFile } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
import { dirname, join } from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
interface IGitState {
|
||||
@@ -29,10 +30,29 @@ export class FailureTracker {
|
||||
{ snapshot: vscode.TestResultSnapshot; failing: IGitState }
|
||||
>();
|
||||
|
||||
private readonly logFile = join(this.rootDir, '.build/vscode-test-failures.json');
|
||||
private readonly logFile: string;
|
||||
private logs?: ITrackedRemediation[];
|
||||
|
||||
constructor(private readonly rootDir: string) {
|
||||
constructor(context: vscode.ExtensionContext, private readonly rootDir: string) {
|
||||
this.logFile = join(context.globalStorageUri.fsPath, '.build/vscode-test-failures.json');
|
||||
mkdirSync(dirname(this.logFile), { recursive: true });
|
||||
|
||||
const oldLogFile = join(rootDir, '.build/vscode-test-failures.json');
|
||||
if (existsSync(oldLogFile)) {
|
||||
try {
|
||||
renameSync(oldLogFile, this.logFile);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
this.disposables.push(
|
||||
vscode.commands.registerCommand('selfhost-test-provider.openFailureLog', async () => {
|
||||
const doc = await vscode.workspace.openTextDocument(this.logFile);
|
||||
await vscode.window.showTextDocument(doc);
|
||||
})
|
||||
);
|
||||
|
||||
this.disposables.push(
|
||||
vscode.tests.onDidChangeTestResults(() => {
|
||||
const last = vscode.tests.testResults[0];
|
||||
|
||||
Reference in New Issue
Block a user