debug
debug copied to clipboard
Adding Test Coverage to Console Tests
Why?
We're looking to shed light on parts of the codebase that could use more tests.
Assumptions
- The coverage report will be viewed locally in HTML format. We haven't planned to sync it with Ruby CI's coverage report yet.
- Is there a way to sync this even if
debugisn't a default gem?
- Is there a way to sync this even if
- Our focus will be on console tests, as they cover most of the debugger's core functionalities.
How?
- We're using
simplecovas our coverage library because it creates an easy-to-read HTML report. - The coverage is only enabled when
ENV["COVERAGE"]is present. - When running tests with coverage enabled, the Ruby script for local console tests will execute
test/support/simplecov_rdbg.rbinstead ofexe/rdbg. This script will:- Require and activate
simplecov. - Configure the debugger to ignore
simplecovrelated calls. - Kick off the program.
- Require and activate
(We need to clear previous results before each run with rm -rf coverage to ensure accuracy for now, but it can easily be turned into a Rake task.)
Issues
We've run into a few issues during the prototyping phase:
simplecovrelies on theat_exithook to generate results, which means that test cases can't usekill!to terminate processes.- This implies that we'll have to update a number of test cases. However, if we can replace
kill!withquit!, this may not be a big issue.
- This implies that we'll have to update a number of test cases. However, if we can replace
- Some tests break when
simplecovruns alongside them. We can mitigate this to some extent by setting theskip_pathconfig. - However, the biggest concern is that some tests take significantly longer to run with
simplecov, leading to timeouts. In addition to that, the entire test suite runs slower, which isn't ideal for developers.