| CoverageTracker | R Documentation |
Tracks which lines of .arl source files actually execute during runtime. Maintains execution counts per file/line and generates reports. Supports flexible configuration for tracking custom directories, test files, and custom comment syntax.
coverageEnvironment mapping "file:line" keys to execution counts
enabledLogical flag to enable/disable tracking
all_filesCharacter vector of all .arl files being tracked
code_linesEnvironment mapping file paths to integer vectors of code line numbers
coverable_linesEnvironment mapping file paths to integer vectors of AST-derived coverable line numbers
new()Initialize the coverage tracker
CoverageTracker$new( search_paths = NULL, include_tests = FALSE, path_strip_patterns = NULL, output_prefix = "arl", report_title = "Arl Code Coverage", code_line_pattern = "^\\s*[^[:space:];]" )
search_pathsCharacter vector of directories to search for .arl files (NULL = use stdlib)
include_testsWhether to include test files in coverage tracking (default: FALSE)
path_strip_patternsCustom regex patterns for stripping paths in reports (NULL = use defaults)
output_prefixSubdirectory name for report outputs (default: "arl")
report_titleTitle to use in coverage reports (default: "Arl Code Coverage")
code_line_patternRegex pattern to identify code lines vs comments/blanks
track()Track execution of an expression with source info
CoverageTracker$track(arl_src)
arl_srcSource information object with file, start_line, end_line
register_coverable()Register coverable lines from an instrumented source range
CoverageTracker$register_coverable(file, start_line, end_line)
fileSource file path
start_lineStart line of the instrumented form
end_lineEnd line of the instrumented form
get_summary()Get coverage summary as list: file -> line -> count
CoverageTracker$get_summary()
discover_files()Discover all .arl files to track
Searches for .arl files in configured search paths or stdlib by default. By default excludes test files unless include_tests = TRUE.
CoverageTracker$discover_files()
reset()Reset coverage data
CoverageTracker$reset()
set_enabled()Enable/disable tracking
CoverageTracker$set_enabled(enabled)
enabledLogical value to enable (TRUE) or disable (FALSE) coverage tracking
report_console()Generate console coverage report
CoverageTracker$report_console(output_file = NULL)
output_fileOptional file to write report to (default: console only)
report_html()Generate HTML coverage report
CoverageTracker$report_html(output_file)
output_filePath to output HTML file (required)
report_json()Generate codecov-compatible JSON format
CoverageTracker$report_json(output_file)
output_filePath to output JSON file (required)
clone()The objects of this class are cloneable with this method.
CoverageTracker$clone(deep = FALSE)
deepWhether to make a deep clone.
This class is exported for use by advanced tooling (CI scripts,
IDE plugins, etc.) and for testing purposes. Its API should be
considered internal and subject to change without notice.
Most users should interact with coverage through the
Engine methods enable_coverage(), disable_coverage(),
get_coverage(), and reset_coverage() instead.
# Track coverage of a single stdlib file (logic.arl)
tracker <- CoverageTracker$new()
engine <- Engine$new(coverage_tracker = tracker, load_prelude = FALSE)
logic_file <- system.file("arl", "logic.arl", package = "arl")
engine$load_file_in_env(logic_file, engine$get_env())
engine$eval(engine$read("(not #t)"))
tracker$report_console()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.