Mercurial > hg > truffle
changeset 20907:06b0a2fb20a1
Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Mon, 13 Apr 2015 11:05:58 -0700 |
parents | c8b83aa6cc82 |
children | f166d264af9f |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/CoverageTracker.java |
diffstat | 1 files changed, 32 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/CoverageTracker.java Mon Apr 13 10:55:15 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/CoverageTracker.java Mon Apr 13 11:05:58 2015 -0700 @@ -35,10 +35,13 @@ /** * An {@link InstrumentationTool} that counts interpreter <em>execution calls</em> to AST nodes that - * hold a specified {@linkplain SyntaxTag tag}, tabulated by source and line number associated with - * each node. Tags are presumed to be applied external to the tool. If no tag is specified, - * {@linkplain StandardSyntaxTag#STATEMENT STATEMENT} is used, corresponding to conventional - * behavior for code coverage tools. + * hold a specified {@linkplain SyntaxTag syntax tag}, tabulated by source and line number + * associated with each node. Syntax tags are presumed to be applied external to the tool. If no tag + * is specified, {@linkplain StandardSyntaxTag#STATEMENT STATEMENT} is used, corresponding to + * conventional behavior for code coverage tools. + * <p> + * No counts will be kept for execution in sources that hold the {@link SourceTag} + * {@link Tags#NO_COVERAGE}. * <p> * <b>Tool Life Cycle</b> * <p> @@ -70,6 +73,30 @@ */ public final class CoverageTracker extends InstrumentationTool { + public enum Tags implements SourceTag { + + /** + * Report no counts for sources holding this tag. + */ + NO_COVERAGE("No Coverage", "Coverage Tracker will igore"); + + private final String name; + private final String description; + + private Tags(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + } + /** Counting data. */ private final Map<LineLocation, CoverageRecord> coverageMap = new HashMap<>(); @@ -264,7 +291,7 @@ final SourceSection srcSection = probe.getProbedSourceSection(); if (srcSection == null) { // TODO (mlvdv) report this? - } else { + } else if (!srcSection.getSource().isTaggedAs(Tags.NO_COVERAGE)) { // Get the source line where the final LineLocation lineLocation = srcSection.getLineLocation(); CoverageRecord record = coverageMap.get(lineLocation);