Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(trace-viewer): update trace file on trace viewer when test completes #498

Merged
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
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 || '';
// if trace viewer is currently displaying the trace file about to be replaced, it needs to be refreshed
const prevTrace = (testItem as any)[traceUrlSymbol];
ruifigueira marked this conversation as resolved.
Show resolved Hide resolved
(testItem as any)[traceUrlSymbol] = trace;
if (enqueuedSingleTest)
if (enqueuedSingleTest || prevTrace === this._traceViewer.currentFile())
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 {
}));
}

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