-
Notifications
You must be signed in to change notification settings - Fork 4.9k
feat: pause on --debug
#38345
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
feat: pause on --debug
#38345
Changes from 22 commits
892e2ce
bcf2fec
c40f102
4b87e41
b26031f
c1c9867
b515837
0a611bb
db2419d
0996534
8381924
d075147
7f90a0f
2242b4c
6061a29
bda2662
3999df2
807eafe
c420d97
c8bd245
dea4b7d
22d0744
dab17dd
7bf8763
5817b37
f768a69
7020ccd
fa8fa14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ export class TeleReporterEmitter implements ReporterV2 { | |
| private _messageSink: (message: teleReceiver.JsonEvent) => void; | ||
| private _rootDir!: string; | ||
| private _emitterOptions: TeleReporterEmitterOptions; | ||
| private _resultKnownErrorsCounts = new Map<string, number>(); | ||
| private _resultKnownAttachmentCounts = new Map<string, number>(); | ||
| // In case there is blob reporter and UI mode, make sure one does override | ||
| // the id assigned by the other. | ||
|
|
@@ -78,6 +79,7 @@ export class TeleReporterEmitter implements ReporterV2 { | |
| timeout: test.timeout, | ||
| annotations: [] | ||
| }; | ||
| this._sendNewErrors(result, test.id); | ||
| this._sendNewAttachments(result, test.id); | ||
| this._messageSink({ | ||
| method: 'onTestEnd', | ||
|
|
@@ -87,17 +89,23 @@ export class TeleReporterEmitter implements ReporterV2 { | |
| } | ||
| }); | ||
|
|
||
| this._resultKnownAttachmentCounts.delete((result as any)[this._idSymbol]); | ||
| const resultId = (result as any)[this._idSymbol] as string; | ||
| this._resultKnownAttachmentCounts.delete(resultId); | ||
| this._resultKnownErrorsCounts.delete(resultId); | ||
| } | ||
|
|
||
| onStepBegin(test: reporterTypes.TestCase, result: reporterTypes.TestResult, step: reporterTypes.TestStep): void { | ||
| (step as any)[this._idSymbol] = createGuid(); | ||
| // This is here to support "test paused" step, where we want to see all errors | ||
| // at the time of the pause. If we were to have `onTestError()` reporter api, this | ||
|
||
| // won't be needed. | ||
| this._sendNewErrors(result, test.id); | ||
Skn0tt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this._messageSink({ | ||
| method: 'onStepBegin', | ||
| params: { | ||
| testId: test.id, | ||
| resultId: (result as any)[this._idSymbol], | ||
| step: this._serializeStepStart(step) | ||
| step: this._serializeStepStart(step), | ||
| } | ||
| }); | ||
| } | ||
|
|
@@ -248,11 +256,26 @@ export class TeleReporterEmitter implements ReporterV2 { | |
| id: (result as any)[this._idSymbol], | ||
| duration: result.duration, | ||
| status: result.status, | ||
| errors: result.errors, | ||
| annotations: result.annotations?.length ? this._relativeAnnotationLocations(result.annotations) : undefined, | ||
| }; | ||
| } | ||
|
|
||
| private _sendNewErrors(result: reporterTypes.TestResult, testId: string) { | ||
| const resultId = (result as any)[this._idSymbol] as string; | ||
| const knownErrorCount = this._resultKnownErrorsCounts.get(resultId) ?? 0; | ||
| if (result.errors.length > knownErrorCount) { | ||
| this._messageSink({ | ||
| method: 'onTestErrors', | ||
| params: { | ||
| testId, | ||
| resultId: (result as any)[this._idSymbol], | ||
| errors: result.errors.slice(knownErrorCount), | ||
| } | ||
| }); | ||
| } | ||
| this._resultKnownErrorsCounts.set(resultId, result.errors.length); | ||
| } | ||
|
|
||
| private _sendNewAttachments(result: reporterTypes.TestResult, testId: string) { | ||
| const resultId = (result as any)[this._idSymbol] as string; | ||
| // Track whether this step (or something else since the last step) has added attachments and send them | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,7 +28,7 @@ import type { ProcessExitData } from './processHost'; | |||||||||||||||||||
| import type { TestGroup } from './testGroups'; | ||||||||||||||||||||
| import type { TestError, TestResult, TestStep } from '../../types/testReporter'; | ||||||||||||||||||||
| import type { FullConfigInternal } from '../common/config'; | ||||||||||||||||||||
| import type { AttachmentPayload, DonePayload, RunPayload, SerializedConfig, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestOutputPayload, TestPausedPayload } from '../common/ipc'; | ||||||||||||||||||||
| import type { AttachmentPayload, DonePayload, RunPayload, SerializedConfig, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestErrorsPayload, TestOutputPayload, TestPausedPayload } from '../common/ipc'; | ||||||||||||||||||||
| import type { Suite } from '../common/test'; | ||||||||||||||||||||
| import type { TestCase } from '../common/test'; | ||||||||||||||||||||
| import type { ReporterV2 } from '../reporters/reporterV2'; | ||||||||||||||||||||
|
|
@@ -322,7 +322,6 @@ class JobDispatcher { | |||||||||||||||||||
| // Do not show more than one error to avoid confusion, but report | ||||||||||||||||||||
| // as interrupted to indicate that we did actually start the test. | ||||||||||||||||||||
| params.status = 'interrupted'; | ||||||||||||||||||||
| params.errors = []; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| const data = this._dataByTestId.get(params.testId); | ||||||||||||||||||||
| if (!data) { | ||||||||||||||||||||
|
|
@@ -333,8 +332,6 @@ class JobDispatcher { | |||||||||||||||||||
| this._remainingByTestId.delete(params.testId); | ||||||||||||||||||||
| const { result, test } = data; | ||||||||||||||||||||
| result.duration = params.duration; | ||||||||||||||||||||
| result.errors = params.errors; | ||||||||||||||||||||
| result.error = result.errors[0]; | ||||||||||||||||||||
| result.status = params.status; | ||||||||||||||||||||
| result.annotations = params.annotations; | ||||||||||||||||||||
| test.annotations = [...params.annotations]; // last test result wins | ||||||||||||||||||||
|
|
@@ -429,6 +426,22 @@ class JobDispatcher { | |||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private _onTestErrors(params: TestErrorsPayload) { | ||||||||||||||||||||
| if (this._failureTracker.hasReachedMaxFailures()) { | ||||||||||||||||||||
| // Do not show more than one error to avoid confusion. | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const data = this._dataByTestId.get(params.testId)!; | ||||||||||||||||||||
dgozman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| if (!data) | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| const { test, result } = data; | ||||||||||||||||||||
| result.errors.push(...params.errors); | ||||||||||||||||||||
| result.error = result.errors[0]; | ||||||||||||||||||||
| for (const error of result.errors) | ||||||||||||||||||||
| this._reporter.onTestError?.(test, result, error); | ||||||||||||||||||||
|
||||||||||||||||||||
| result.errors.push(...params.errors); | |
| result.error = result.errors[0]; | |
| for (const error of result.errors) | |
| this._reporter.onTestError?.(test, result, error); | |
| for (const error of params.errors) { | |
| result.errors.push(error); | |
| result.error = result.errors[0]; | |
| this._reporter.onTestError?.(test, result, error); | |
| } |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| result.errors.push(...errors); | |
| result.error = result.errors[0]; | |
| for (const error of result.errors) | |
| this._reporter.onTestError?.(test, result, error); | |
| for (const error of errors) { | |
| result.errors.push(error); | |
| result.error = result.errors[0]; | |
| this._reporter.onTestError?.(test, result, error); | |
| } |
Uh oh!
There was an error while loading. Please reload this page.