Skip to content

Commit

Permalink
Add test to cover falling back to matching on name instead of key
Browse files Browse the repository at this point in the history
  • Loading branch information
jlfwong committed Oct 25, 2020
1 parent 2726680 commit 658965e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sample/profiles/trace-event/event-reordering-name-match.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{"tid": 1, "ph": "X", "pid": 0, "name": "alpha", "args": {"x": 0}, "ts": 0, "dur": 10},
{"tid": 1, "ph": "B", "pid": 0, "name": "beta", "args": {"x": 0}, "ts": 1},
{"tid": 1, "ph": "B", "pid": 0, "name": "gamma", "args": {"x": 0}, "ts": 1},
{"tid": 1, "ph": "E", "pid": 0, "name": "beta", "args": {"x": 1}, "ts": 2},
{"tid": 1, "ph": "E", "pid": 0, "name": "gamma", "args": {"x": 1}, "ts": 2}
]
44 changes: 44 additions & 0 deletions src/import/__snapshots__/trace-event.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,50 @@ exports[`importTraceEvents event re-ordering: indexToView 1`] = `0`;

exports[`importTraceEvents event re-ordering: profileGroup.name 1`] = `"must-retain-original-order.json"`;

exports[`importTraceEvents event reordering name match 1`] = `
Object {
"frames": Array [
Frame {
"col": undefined,
"file": undefined,
"key": "alpha {\\"x\\":0}",
"line": undefined,
"name": "alpha {\\"x\\":0}",
"selfWeight": 9,
"totalWeight": 10,
},
Frame {
"col": undefined,
"file": undefined,
"key": "beta {\\"x\\":0}",
"line": undefined,
"name": "beta {\\"x\\":0}",
"selfWeight": 0,
"totalWeight": 1,
},
Frame {
"col": undefined,
"file": undefined,
"key": "gamma {\\"x\\":0}",
"line": undefined,
"name": "gamma {\\"x\\":0}",
"selfWeight": 1,
"totalWeight": 1,
},
],
"name": "pid 0, tid 1",
"stacks": Array [
"alpha {\\"x\\":0} 1.00µs",
"alpha {\\"x\\":0};beta {\\"x\\":0};gamma {\\"x\\":0} 1.00µs",
"alpha {\\"x\\":0} 8.00µs",
],
}
`;

exports[`importTraceEvents event reordering name match: indexToView 1`] = `0`;

exports[`importTraceEvents event reordering name match: profileGroup.name 1`] = `"event-reordering-name-match.json"`;

exports[`importTraceEvents invalid x nesting 1`] = `
Object {
"frames": Array [
Expand Down
4 changes: 4 additions & 0 deletions src/import/trace-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ test('importTraceEvents BEX interaction', async () => {
test('importTraceEvents invalid x nesting', async () => {
await checkProfileSnapshot('./sample/profiles/trace-event/invalid-x-nesting.json')
})

test('importTraceEvents event reordering name match', async () => {
await checkProfileSnapshot('./sample/profiles/trace-event/event-reordering-name-match.json')
})

0 comments on commit 658965e

Please sign in to comment.