-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[DebuggerV2] Highlight stack frame being shown in SourceCodeComponent #3550
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
Conversation
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.
Looks good! Just some minor comments
| expect(functionElements[2].nativeElement.innerText).toEqual( | ||
| stackFrame2[3] | ||
| expect(focusedFilePathElement.nativeElement.innerText).toBe( | ||
| stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1) |
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.
This same slicing logic is on L928, 932, 936. Perhaps create a helper function?
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.
Since this is a test, I'll opt not to add a helper function now. It's my preference to keep test logic explicit even when it's sometimes a little more verbose.
| expect(filePathElements[0].nativeElement.innerText).toEqual( | ||
| expect(filePathElements.length).toBe(3); | ||
| expect(filePathElements[0].nativeElement.innerText).toBe( | ||
| stackFrame0[1].slice(stackFrame0[1].lastIndexOf('/') + 1) |
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.
While reading this test, I found myself going back to lookup which indices in the stackFrame array correspond to which fields. I think it might be helpful for readability if createTestStackFrame returned an object with named properties like 'filePath'. Although since that was outside of this PR, it's fine to not change in this PR.
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.
I add a TODO item to debugger_types.ts. The background here is this is how Python's traceback.extract_tb returns tuples like (file_path, lineno, function_name). So this "leaks" into the data types in debugger v2 a little.
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.
Awesome, thanks for the todo+context.
| expect(filePathElements[1].nativeElement.innerText).toBe( | ||
| stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1) | ||
| ); | ||
| expect(filePathElements[1].nativeElement.title).toEqual(stackFrame1[1]); |
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.
Can this also use toBe?
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.
Yes. Done.
| ); | ||
| expect(stackFrameContainers.length).toEqual(0); | ||
| }); | ||
|
|
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.
Use toBe on L1028?
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.
Done.
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.
Thanks for the review!
| expect(filePathElements[1].nativeElement.innerText).toBe( | ||
| stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1) | ||
| ); | ||
| expect(filePathElements[1].nativeElement.title).toEqual(stackFrame1[1]); |
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.
Yes. Done.
| expect(functionElements[2].nativeElement.innerText).toEqual( | ||
| stackFrame2[3] | ||
| expect(focusedFilePathElement.nativeElement.innerText).toBe( | ||
| stackFrame1[1].slice(stackFrame1[1].lastIndexOf('/') + 1) |
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.
Since this is a test, I'll opt not to add a helper function now. It's my preference to keep test logic explicit even when it's sometimes a little more verbose.
| ); | ||
| expect(stackFrameContainers.length).toEqual(0); | ||
| }); | ||
|
|
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.
Done.
| expect(filePathElements[0].nativeElement.innerText).toEqual( | ||
| expect(filePathElements.length).toBe(3); | ||
| expect(filePathElements[0].nativeElement.innerText).toBe( | ||
| stackFrame0[1].slice(stackFrame0[1].lastIndexOf('/') + 1) |
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.
I add a TODO item to debugger_types.ts. The background here is this is how Python's traceback.extract_tb returns tuples like (file_path, lineno, function_name). So this "leaks" into the data types in debugger v2 a little.
…tensorflow#3550) * Motivation for features / changes * Make it clearer in the StackFrameComponent which frame (if any) is being highlighted in the SourceCodeComponent. * Technical description of changes * In StackFrameContainer's internal selector, add a boolean field to the return value called `focused`. It is used in the template ng html to apply a CSS class (`.focused-stack-frame`) to the focused stack frame and only the focused stack frame. * While adding new unit test for the new feature, simplify existing ones by using `overrideSelector`. * To conform to style guide, replace `toEqual()` with `toBe()` where applicable in the touched unit tests. * Screenshots of UI changes *  * Detailed steps to verify changes work correctly (as executed by you) * Unit test added * Existing unit tests for `StackFrameContainer` are simplified by replacing `setState()` with `overrideSelector()`.
…#3550) * Motivation for features / changes * Make it clearer in the StackFrameComponent which frame (if any) is being highlighted in the SourceCodeComponent. * Technical description of changes * In StackFrameContainer's internal selector, add a boolean field to the return value called `focused`. It is used in the template ng html to apply a CSS class (`.focused-stack-frame`) to the focused stack frame and only the focused stack frame. * While adding new unit test for the new feature, simplify existing ones by using `overrideSelector`. * To conform to style guide, replace `toEqual()` with `toBe()` where applicable in the touched unit tests. * Screenshots of UI changes *  * Detailed steps to verify changes work correctly (as executed by you) * Unit test added * Existing unit tests for `StackFrameContainer` are simplified by replacing `setState()` with `overrideSelector()`.
focused. It is used in the template ng html to apply a CSS class (.focused-stack-frame) to the focused stack frame and only the focused stack frame.overrideSelector.toEqual()withtoBe()where applicable in the touched unit tests.StackFrameContainerare simplified by replacingsetState()withoverrideSelector().