eng: make it selfhost failure log easier to access and more stable (#212626)

This commit is contained in:
Connor Peet
2024-05-13 11:35:03 -07:00
committed by GitHub
parent 501b2bb22c
commit 929bec07f1
3 changed files with 35 additions and 9 deletions

View File

@@ -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];