Skip to content

Commit

Permalink
bug(trace-viewer): fix error on live trace viewer from vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
ruifigueira committed Jun 14, 2024
1 parent f5038c4 commit 0d97bbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,10 @@ export class Extension implements RunHooks {
return;

const trace = result.attachments.find(a => a.name === 'trace')?.path || '';
const prevTrace = (testItem as any)[traceUrlSymbol];
(testItem as any)[traceUrlSymbol] = trace;
if (enqueuedSingleTest)
if (enqueuedSingleTest || prevTrace === this._traceViewer.currentFile)
// refresh the trace viewer
this._showTrace(testItem);

if (result.status === test.expectedStatus) {
Expand Down
7 changes: 7 additions & 0 deletions src/traceViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class TraceViewer implements vscodeTypes.Disposable {
private _disposables: vscodeTypes.Disposable[] = [];
private _traceViewerProcess: ChildProcess | undefined;
private _settingsModel: SettingsModel;
private _currentFile?: string;

constructor(vscode: vscodeTypes.VSCode, settingsModel: SettingsModel, envProvider: () => NodeJS.ProcessEnv) {
this._vscode = vscode;
Expand All @@ -38,6 +39,10 @@ export class TraceViewer implements vscodeTypes.Disposable {
}));
}

get currentFile() {
return this._currentFile;
}

async willRunTests(config: TestConfig) {
if (this._settingsModel.showTrace.get())
await this._startIfNeeded(config);
Expand All @@ -52,6 +57,7 @@ export class TraceViewer implements vscodeTypes.Disposable {
return;
await this._startIfNeeded(config);
this._traceViewerProcess?.stdin?.write(file + '\n');
this._currentFile = file;
}

dispose() {
Expand Down Expand Up @@ -85,6 +91,7 @@ export class TraceViewer implements vscodeTypes.Disposable {
traceViewerProcess.stderr?.on('data', data => console.log(data.toString()));
traceViewerProcess.on('exit', () => {
this._traceViewerProcess = undefined;
this._currentFile = undefined;
});
traceViewerProcess.on('error', error => {
this._vscode.window.showErrorMessage(error.message);
Expand Down

0 comments on commit 0d97bbe

Please sign in to comment.