# HG changeset patch # User Michael Van De Vanter # Date 1428948358 25200 # Node ID 06b0a2fb20a16700f6945cbf43dc4857edff083f # Parent c8b83aa6cc827f33dd56d5d8a3eca84822f842df Truffle/Tools: the coverage tool will now ignore counts for any sources holding the tag CoverageTracker.Tags.NO_COVERAGE. diff -r c8b83aa6cc82 -r 06b0a2fb20a1 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/CoverageTracker.java --- 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 execution calls 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. + *

+ * No counts will be kept for execution in sources that hold the {@link SourceTag} + * {@link Tags#NO_COVERAGE}. *

* Tool Life Cycle *

@@ -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 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);