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

fix broken test cases and add tests for [frame] bug. #70

Merged
merged 3 commits into from
Jan 8, 2024
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: 2 additions & 2 deletions flameshow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def render_one_frame_detail(
raise NotImplementedError

@property
def title(self) -> str:
def title(self) -> Text:
"""Full name which will be displayed in the frame detail panel"""
return self.name
return Text(self.name)

@property
def color_key(self):
Expand Down
2 changes: 2 additions & 0 deletions tests/stackcollapse_data/simple_square.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a;b;[c] 1
a;[b];d 4
17 changes: 16 additions & 1 deletion tests/test_stackcollapse_parse/test_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from rich.text import Text
from flameshow.parsers.stackcollapse_parser import StackCollapseFrame


Expand All @@ -6,4 +7,18 @@ def test_frame_model_render():
"java::abc", 1, parent=None, children=[], values=[13]
)
render_result = f.render_one_frame_detail(f, 0, "count")
assert render_result == ["java::abc\n"]
assert len(render_result) == 1
item = render_result[0]
assert item.markup == "java::abc\n"


def test_frame_model_render_with_square():
f = StackCollapseFrame("[abc]", 1, parent=None, children=[], values=[13])
render_result = f.render_one_frame_detail(f, 0, "count")
assert len(render_result) == 1
item = render_result[0]
assert item.markup == "\\[abc]\n"

title = f.title
assert isinstance(title, Text)
assert title.plain == "[abc]"
82 changes: 36 additions & 46 deletions tests/test_stackcollapse_parse/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@ def test_parse_simple_text_data(simple_collapse_data):

assert frame2json(profile.root_stack) == {
"root": {
"children": [
{
"a": {
"children": [
{
"b": {
"children": [
{"c": {"children": [], "values": [5]}},
{"d": {"children": [], "values": [4]}},
],
"values": [14],
}
}
],
"values": [14],
}
"children": [{
"a": {
"children": [{
"b": {
"children": [
{"c": {"children": [], "values": [5]}},
{"d": {"children": [], "values": [4]}},
],
"values": [14],
}
}],
"values": [14],
}
],
}],
"values": [14],
},
}
Expand Down Expand Up @@ -98,16 +94,14 @@ def test_validate_simple_text_data_contains_numbers_somtimes_parsing():
"children": [
{
"a": {
"children": [
{
"b": {
"children": [
{"c": {"children": [], "values": [10]}}
],
"values": [10],
}
"children": [{
"b": {
"children": [
{"c": {"children": [], "values": [10]}}
],
"values": [10],
}
],
}],
"values": [10],
}
},
Expand All @@ -125,28 +119,24 @@ def test_space_and_numbers_in_stackcollapse_symbols():
profile = StackCollapseParser("a.txt").parse(data)
assert frame2json(profile.root_stack) == {
"root": {
"children": [
{
"a 1": {
"children": [
{
"b 2": {
"children": [
{
"c 3": {
"children": [],
"values": [10],
}
}
],
"values": [10],
"children": [{
"a 1": {
"children": [{
"b 2": {
"children": [
{
"c 3": {
"children": [],
"values": [10],
}
}
}
],
"values": [10],
}
],
"values": [10],
}
}],
"values": [10],
}
],
}],
"values": [10],
},
}
Loading