You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 23, 2023. It is now read-only.
Patches to add code coverage support in the R interpreter.
Overview
This repository contains patches of the R interpreter source code to add code coverage support.
It allows to know which exact lines of source code were exercized/hit/covered while running some piece of code (usually a test suite).
The easiest way to test it is using our docker container: https://github.com/quartzbio/r-coverage-docker
Installation
As stated above, you can just use the docker container.
To patch it manually:
choose the appropriate patch corresponding to the version of the R interpreter you are going to use.
get the source code of the R version (download and untar)
patch the source code (patch)
configure the source directory (./configure)
compile and install (make; make install)
The project is organized in sudirectories per supported R version, e.g. r302 for R version 3.0.2.
The above steps are somewhat automated using a Makefile (you need probably GNU make).
For example, to download, untar, patch, configure, make and install R-3.0.2:
git clone https://github.com/quartzbio/r-coverage-patch.git
cd r-coverage-patch/r302/
# download, untar and patch
make apply_production_patch
# install in ./local/
make install
# Or install in a custom place
make install PREFIX=/whatever/
# run it
./local/bin/R
Implementation
I added a condition in the internal C function getSrcref(), that records the line numbers if the code
coverage is started (via Rcov_start()).
The overhead should be minimal since for a given file, subsequent covered lines will be stored
in constant time.
I use a hashed env to store the occurrences by file.
I added two entry points in the utils package (Rcov_start() and Rcov_stop())