-
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
Open
Skn0tt
wants to merge
19
commits into
microsoft:main
Choose a base branch
from
Skn0tt:pause-on-debug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+318
−53
Open
feat: pause on --debug
#38345
Changes from all commits
Commits
Show all changes
19 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 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
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 |
|---|---|---|
|
|
@@ -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, TestErrorPayload, 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 | ||
|
|
@@ -398,8 +395,10 @@ class JobDispatcher { | |
| return; | ||
| } | ||
| step.duration = params.wallTime - step.startTime.getTime(); | ||
| if (params.error) | ||
| if (params.error) { | ||
| addLocationAndSnippetToError(this._config.config, params.error, test.location.file); | ||
| step.error = params.error; | ||
| } | ||
| if (params.suggestedRebaseline) | ||
| addSuggestedRebaseline(step.location!, params.suggestedRebaseline); | ||
| step.annotations = params.annotations; | ||
|
|
@@ -429,6 +428,22 @@ class JobDispatcher { | |
| } | ||
| } | ||
|
|
||
| private _onErrors(params: TestErrorPayload) { | ||
| if (this._failureTracker.hasReachedMaxFailures()) { | ||
| // Do not show more than one error to avoid confusion. | ||
| return; | ||
| } | ||
|
|
||
| const data = this._dataByTestId.get(params.testId)!; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should check |
||
| if (!data) | ||
| return; | ||
| const { result } = data; | ||
| for (const error of params.errors) | ||
| addLocationAndSnippetToError(this._config.config, error, data.test.location.file); | ||
| result.errors.push(...params.errors); | ||
| result.error = result.errors[0]; | ||
| } | ||
|
|
||
| private _failTestWithErrors(test: TestCase, errors: TestError[]) { | ||
| const runData = this._dataByTestId.get(test.id); | ||
| // There might be a single test that has started but has not finished yet. | ||
|
|
@@ -439,7 +454,9 @@ class JobDispatcher { | |
| result = test._appendTestResult(); | ||
| this._reporter.onTestBegin?.(test, result); | ||
| } | ||
| result.errors = [...errors]; | ||
| for (const error of errors) | ||
| addLocationAndSnippetToError(this._config.config, error, test.location.file); | ||
| result.errors.push(...errors); | ||
| result.error = result.errors[0]; | ||
| result.status = errors.length ? 'failed' : 'skipped'; | ||
| this._reportTestEnd(test, result); | ||
|
|
@@ -578,31 +595,34 @@ class JobDispatcher { | |
| eventsHelper.addEventListener(worker, 'stepBegin', this._onStepBegin.bind(this)), | ||
| eventsHelper.addEventListener(worker, 'stepEnd', this._onStepEnd.bind(this)), | ||
| eventsHelper.addEventListener(worker, 'attach', this._onAttach.bind(this)), | ||
| eventsHelper.addEventListener(worker, 'testErrors', this._onErrors.bind(this)), | ||
| eventsHelper.addEventListener(worker, 'testPaused', this._onTestPaused.bind(this, worker)), | ||
| eventsHelper.addEventListener(worker, 'done', this._onDone.bind(this)), | ||
| eventsHelper.addEventListener(worker, 'exit', this.onExit.bind(this)), | ||
| ]; | ||
| } | ||
|
|
||
| private _onTestPaused(worker: WorkerHost, params: TestPausedPayload) { | ||
| const data = this._dataByTestId.get(params.testId); | ||
| if (!data) | ||
| return; | ||
|
|
||
| const sendMessage = async (message: { request: any }) => { | ||
| try { | ||
| if (this.jobResult.isDone()) | ||
| throw new Error('Test has already stopped'); | ||
| const response = await worker.sendCustomMessage({ testId: params.testId, request: message.request }); | ||
| if (response.error) | ||
| addLocationAndSnippetToError(this._config.config, response.error); | ||
| addLocationAndSnippetToError(this._config.config, response.error, data.test.location.file); | ||
| return response; | ||
| } catch (e) { | ||
| const error = serializeError(e); | ||
| addLocationAndSnippetToError(this._config.config, error); | ||
| addLocationAndSnippetToError(this._config.config, error, data.test.location.file); | ||
| return { response: undefined, error }; | ||
| } | ||
| }; | ||
|
|
||
| for (const error of params.errors) | ||
| addLocationAndSnippetToError(this._config.config, error); | ||
| this._failureTracker.onTestPaused?.({ ...params, sendMessage }); | ||
| this._failureTracker.onTestPaused?.({ errors: data.result.errors, sendMessage }); | ||
| } | ||
|
|
||
| skipWholeJob(): boolean { | ||
|
|
||
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.