-
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
Merged
+317
−50
Merged
feat: pause on --debug
#38345
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
892e2ce
feat: --debug pauses test
Skn0tt bcf2fec
location
Skn0tt c40f102
proper step location
Skn0tt 4b87e41
progressively report errors
Skn0tt b26031f
tele
Skn0tt c1c9867
skip on windows
Skn0tt b515837
reporting more errors
Skn0tt 0a611bb
errors are optional
Skn0tt db2419d
mark optional for backwards compat
Skn0tt 0996534
extract into TestErrorPayload ipc
Skn0tt 8381924
mirror attachments
Skn0tt d075147
typescript
Skn0tt 7f90a0f
unflake
Skn0tt 2242b4c
style
Skn0tt 6061a29
more feedback
Skn0tt bda2662
feedback
Skn0tt 3999df2
add snippets in dispatcher
Skn0tt 807eafe
merge
Skn0tt c420d97
pass file when possible
Skn0tt c8bd245
add comment
Skn0tt dea4b7d
address
Skn0tt 22d0744
rename
Skn0tt dab17dd
rename
Skn0tt 7bf8763
maintain last error index
Skn0tt 5817b37
use onTestError
Skn0tt f768a69
remove unused map
Skn0tt 7020ccd
revert linechange
Skn0tt fa8fa14
the multiplexer!
Skn0tt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,6 @@ export class InternalReporter implements ReporterV2 { | |
| } | ||
|
|
||
| onTestEnd(test: TestCase, result: TestResult) { | ||
| this._addSnippetToTestErrors(test, result); | ||
| this._reporter.onTestEnd?.(test, result); | ||
| } | ||
|
|
||
|
|
@@ -89,7 +88,7 @@ export class InternalReporter implements ReporterV2 { | |
| } | ||
|
|
||
| onError(error: TestError) { | ||
| addLocationAndSnippetToError(this._config, error); | ||
| addLocationAndSnippetToError(this._config, error, undefined); | ||
| this._reporter.onError?.(error); | ||
| } | ||
|
|
||
|
|
@@ -98,26 +97,15 @@ export class InternalReporter implements ReporterV2 { | |
| } | ||
|
|
||
| onStepEnd(test: TestCase, result: TestResult, step: TestStep) { | ||
| this._addSnippetToStepError(test, step); | ||
| this._reporter.onStepEnd?.(test, result, step); | ||
| } | ||
|
|
||
| printsToStdio() { | ||
| return this._reporter.printsToStdio ? this._reporter.printsToStdio() : true; | ||
| } | ||
|
|
||
| private _addSnippetToTestErrors(test: TestCase, result: TestResult) { | ||
| for (const error of result.errors) | ||
| addLocationAndSnippetToError(this._config, error, test.location.file); | ||
| } | ||
|
|
||
| private _addSnippetToStepError(test: TestCase, step: TestStep) { | ||
| if (step.error) | ||
| addLocationAndSnippetToError(this._config, step.error, test.location.file); | ||
| } | ||
| } | ||
|
|
||
| export function addLocationAndSnippetToError(config: FullConfig, error: TestError, file?: string) { | ||
| export function addLocationAndSnippetToError(config: FullConfig, error: TestError, file: string | undefined) { | ||
| if (error.stack && !error.location) | ||
| error.location = prepareErrorStack(error.stack).location; | ||
| const location = error.location; | ||
|
|
@@ -129,7 +117,7 @@ export function addLocationAndSnippetToError(config: FullConfig, error: TestErro | |
| const source = fs.readFileSync(location.file, 'utf8'); | ||
| const codeFrame = codeFrameColumns(source, { start: location }, { highlightCode: true }); | ||
| // Convert /var/folders to /private/var/folders on Mac. | ||
| if (!file || fs.realpathSync(file) !== location.file) { | ||
| if (!file || fs.realpathSync(file) !== location.file && false) { | ||
|
||
| tokens.push(internalScreen.colors.gray(` at `) + `${relativeFilePath(internalScreen, config, location.file)}:${location.line}`); | ||
| tokens.push(''); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.