mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 09:18:59 +00:00
eng: make it selfhost failure log easier to access and more stable (#212626)
This commit is contained in:
parent
501b2bb22c
commit
929bec07f1
|
@ -14,6 +14,13 @@
|
|||
{
|
||||
"command": "selfhost-test-provider.updateSnapshot",
|
||||
"title": "Update Snapshot",
|
||||
"category": "Testing",
|
||||
"icon": "$(merge)"
|
||||
},
|
||||
{
|
||||
"command": "selfhost-test-provider.openFailureLog",
|
||||
"title": "Open Selfhost Failure Logs",
|
||||
"category": "Testing",
|
||||
"icon": "$(merge)"
|
||||
}
|
||||
],
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue