Improve test coverage for codebase
- Dominant language
- Rust
- Stars
- 2.2k
- Forks
- 160
- PR merge metrics
- No merged PRs in 30d
Description
The [code coverage](https://codecov.io/gh/jonhoo/inferno/tree/master/src) of our tests is good, but not as good as we'd like it to be. In particular, I see some obvious candidates for new tests.
In `perf` stack collapsing ([see coverage report](https://codecov.io/gh/jonhoo/inferno/src/master/src/collapse/perf.rs)):
- [x] Collapsing a `perf` trace with an [empty line](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/collapse/perf.rs#L192).
- [x] Collapsing a `perf` trace with a ["weird" event line](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/collapse/perf.rs#L354).
- [ ] Collapsing a `perf` trace with a ["process name"](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/collapse/perf.rs#L302).
- [x] Collapsing a `perf` trace with an [inline Java function](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/collapse/perf.rs#L334).
- [x] Collapsing a `perf` trace with a ["weird" stack line](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/collapse/perf.rs#L354).
- [x] Collapse a profile with [Go names](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/collapse/perf.rs#L551).
In DTrace stack collapsing ([see coverage report](https://codecov.io/gh/jonhoo/inferno/src/master/src/collapse/dtrace.rs)):
- [x] Collapse a file with [only header lines](https://github.com/jonhoo/inferno/blob/76508029643aba8cadc9b306cdf115469df8bb88/src/collapse/dtrace.rs#L49).
- [x] Collapse a file with a line that has `::`, but _not_ a [trailing argument list](https://github.com/jonhoo/inferno/blob/76508029643aba8cadc9b306cdf115469df8bb88/src/collapse/dtrace.rs#L97).
Stack collapsing [in general](https://codecov.io/gh/jonhoo/inferno/src/master/src/collapse/mod.rs):
- [x] Collapse using [`collapse_file`](https://github.com/jonhoo/inferno/blob/10a1fd7c4c891dbc6a3c6ed74541d884eb89b1e9/src/collapse/mod.rs#L35).
- [x] Collapse using `collapse_file` [on `STDIN`](https://github.com/jonhoo/inferno/blob/082b301f5f4ce0efec718e38dd75ca1f7bf10abb/src/collapse/mod.rs#L53L58).
In `flamegraph` ([see coverage report](https://codecov.io/gh/jonhoo/inferno/src/master/src/flamegraph/mod.rs)):
- [x] Use a [palette file](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/mod.rs#L231).
- [x] [Ignore bad lines](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/mod.rs#L241).
- [x] Plot [an empty trace](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/mod.rs#L246L270).
- [x] Plot a file where frames [get pruned](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/mod.rs#L280).
- [x] Plot an [inverted flame graph](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/mod.rs#L314L318).
- [x] Include [grey frames](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/mod.rs#L420L423).
- [x] Test a non-sorted [multi-reader input](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/mod.rs#L525).
- [ ] Add tests for all the various [color mappings](https://codecov.io/gh/jonhoo/inferno/src/master/src/flamegraph/color/mod.rs).
- [x] Add unit tests for [Java semantic coloring](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/color/palettes.rs#L8).
- [x] Add unit tests for [Perl semantic coloring](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/color/palettes.rs#L55).
- [x] Add unit tests for [JavaScript semantic coloring](https://github.com/jonhoo/inferno/blob/4863e01504e795726f31e751eadbe66f9337faad/src/flamegraph/color/palettes.rs#L71).
- [x] Add tests for various [malformed palette lines](https://github.com/jonhoo/inferno/blob/59a9dacc6103a4f08dece2a54fedd012699fd5b3/src/flamegraph/color/palette_map.rs#L31L43) (see [coverage](https://codecov.io/gh/jonhoo/inferno/src/master/src/flamegraph/color/palette_map.rs)).
- [ ] Add a test that has to [generate colors](https://github.com/jonhoo/inferno/blob/2bfb7026907c35a5cd8b32734f23a63788d732c9/src/flamegraph/color/palette_map.rs#L113L117) (you may need to enable `hash`).
- [x] Add tests for various [malformed nameattribute lines](https://codecov.io/gh/jonhoo/inferno/src/master/src/flamegraph/attrs.rs).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the unchecked cases in src/collapse/perf.rs, src/flamegraph/color/mod.rs, and src/flamegraph/color/palette_map.rs, using the linked coverage locations and existing tests as entry points. Add coverage for the listed process-name, color-mapping, and generated-color scenarios, then run the test suite; done means the remaining unchecked items have tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing-qa
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100