Truffle Instrumentation to collect coverage information for for all Truffle languages.
Java Slash
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

CoverallsTruffle: Language Agnostic Coverage Tracking for Truffle

Truffle is an open-source framework for the implementation of high-performance language runtimes using Java and the Java Virtual Machine (JVM). is a web service to help you track code coverage, for instance to ensure that new code is covered by tests.

CoverallsTruffle uses the Truffle Instrumentation framework to collect coverage information, i.e., executed and not executed lines, and send it to to evaluate the coverage.

How To Use

To use, you'll need an account and register the relevant project repositories. does not store source code itself, but accesses for instance GitHub or BitBucket.

To report results, assigns each project a repo_token that needs to be passed to CoverallsTruffle.

CoverallsTruffle can be used similar to other Truffle instruments by enabling it when configuring the PolyglotEngine. It needs to be enabled and configure with the custom repository token and optionally a service name. For details see the Coveralls documentation.

PolyglotEngine engine = PolyglotEngine.newBuilder().build();
Instrument covInst = engine.getInstruments().get(Coverage.ID);
covInst.setEnabled(true); // enable the instrument

// configure coverage instrument
Coverage coverage = engineInst.lookup(Coverage.class);
coverage.setRepoToken("YOUR_TOKEN");  // Needs to be updated
coverage.setServiceName("travis-ci"); // Set the service_name, see Coveralls documentation

// start execution as usual.

For further examples, see Tests, which uses the SimpleLanguage to check that the coverage is determined correctly, as well as the coverage support for SOMns introduced with commit dc381d. An example coverage report for the SOMns core library is

Implementation Overview

The main classes are:


  • onCreate(.) registers instrumentation for StatementTag.
  • onDispose(.) processes the data from the instrumentation to determine the executed lines of code from the AST and sends the results as JSON to

CountingNode: instruments AST nodes with the StatementTag and increments a counter each time the AST node is executed.

Counter: encapsulates the value of the counter and the source section to which is related.