1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.devtools.resultstore.v2; 18 19option go_package = "google.golang.org/genproto/googleapis/devtools/resultstore/v2;resultstore"; 20option java_multiple_files = true; 21option java_outer_classname = "CoverageProto"; 22option java_package = "com.google.devtools.resultstore.v2"; 23 24// Describes line coverage for a file 25message LineCoverage { 26 // Which source lines in the file represent the start of a statement that was 27 // instrumented to detect whether it was executed by the test. 28 // 29 // This is a bitfield where i-th bit corresponds to the i-th line. Divide line 30 // number by 8 to get index into byte array. Mod line number by 8 to get bit 31 // number (0 = LSB, 7 = MSB). 32 // 33 // A 1 denotes the line was instrumented. 34 // A 0 denotes the line was not instrumented. 35 bytes instrumented_lines = 1; 36 37 // Which of the instrumented source lines were executed by the test. Should 38 // include lines that were not instrumented. 39 // 40 // This is a bitfield where i-th bit corresponds to the i-th line. Divide line 41 // number by 8 to get index into byte array. Mod line number by 8 to get bit 42 // number (0 = LSB, 7 = MSB). 43 // 44 // A 1 denotes the line was executed. 45 // A 0 denotes the line was not executed. 46 bytes executed_lines = 2; 47} 48 49// Describes branch coverage for a file 50message BranchCoverage { 51 // The field branch_present denotes the lines containing at least one branch. 52 // 53 // This is a bitfield where i-th bit corresponds to the i-th line. Divide line 54 // number by 8 to get index into byte array. Mod line number by 8 to get bit 55 // number (0 = LSB, 7 = MSB). 56 // 57 // A 1 denotes the line contains at least one branch. 58 // A 0 denotes the line contains no branches. 59 bytes branch_present = 1; 60 61 // Contains the number of branches present, only for the lines which have the 62 // corresponding bit set in branch_present, in a relative order ignoring 63 // lines which do not have any branches. 64 repeated int32 branches_in_line = 2; 65 66 // As each branch can have any one of the following three states: not 67 // executed, executed but not taken, executed and taken. 68 // 69 // This is a bitfield where i-th bit corresponds to the i-th branch. Divide 70 // branch number by 8 to get index into byte array. Mod branch number by 8 to 71 // get bit number (0 = LSB, 7 = MSB). 72 // 73 // i-th bit of the following two byte arrays are used to denote the above 74 // mentioned states. 75 // 76 // not executed: i-th bit of executed == 0 && i-th bit of taken == 0 77 // executed but not taken: i-th bit of executed == 1 && i-th bit of taken == 0 78 // executed and taken: i-th bit of executed == 1 && i-th bit of taken == 1 79 bytes executed = 3; 80 81 // Described above. 82 bytes taken = 4; 83} 84 85// Describes code coverage for a particular file under test. 86message FileCoverage { 87 // Path of source file within the SourceContext of this Invocation. 88 string path = 1; 89 90 // Details of lines in a file for calculating line coverage. 91 LineCoverage line_coverage = 2; 92 93 // Details of branches in a file for calculating branch coverage. 94 BranchCoverage branch_coverage = 3; 95} 96 97// Describes code coverage for a build or test Action. This is used to store 98// baseline coverage for build Actions and test coverage for test Actions. 99message ActionCoverage { 100 // List of coverage info for all source files that the TestResult covers. 101 repeated FileCoverage file_coverages = 2; 102} 103 104// Describes aggregate code coverage for a collection of build or test Actions. 105// A line or branch is covered if and only if it is covered in any of the build 106// or test actions. 107message AggregateCoverage { 108 // Aggregated coverage info for all source files that the actions cover. 109 repeated FileCoverage file_coverages = 1; 110} 111