1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# -*- python -*-
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Example configuration file for Croc
# Basic formatting rules:
# * It looks like JSON.
# * It's really python.
# * Dictionaries are wrapped in {}. Order does not matter. Entries are of
# the form:
# 'key':value,
# Note the trailing comma, which will help save you from python's built-in
# string concatenation.
# * Lists are wrapped in []. Order does matter. Entries should be followed
# with a trailing comma, which will help save you from python's built-in
# string concatenation.
# * Comments start with # and extend to end of line.
# * Strings are wrapped in ''. Backslashes must be escaped ('foo\\bar', not
# 'foo\bar') - this is particularly important in rule regular expressions.
# What follows is the main configuration dictionary.
{
# List of root directories, applied in order.
#
# Typically, coverage data files contain absolute paths to the sources.
# What you care about is usually a relative path from the top of your source
# tree (referred to here as a 'source root') to the sources.
#
# Roots may also be specified on the command line via the --root option.
# Roots specified by --root are applied before those specified in config
# files.
'roots' : [
# Each entry is a dict.
# * It must contain a 'root' entry, which is the start of a path.
# * Root entries may be absolute paths
# * Root entries starting with './' or '../' are relative paths, and
# are taken relative to the current directory where you run croc.
# * Root entries may start with previously defined altnames.
# * Use '/' as a path separator, even on Windows.
# * It may contain a 'altname' entry. If the root matches the start of
# a filename, that start is replaced with the 'altname', or with '_'
# if no default is specified.
# * Multiple root entries may share the same altname. This is commonly
# used when combining LCOV files from different platforms into one
# coverage report, when each platform checks out source code into a
# different source tree.
{'root' : 'c:/P4/EarthHammer'},
{'root' : 'd:/pulse/recipes/330137642/base'},
{'root' : '/Volumes/BuildData/PulseData/data/recipes/330137640/base'},
{'root' : '/usr/local/google/builder/.pulse-agent/data/recipes/330137641/base'},
# Sub-paths we specifically care about and want to call out. Note that
# these are relative to the default '_' altname.
{
'root' : '_/googleclient/third_party/software_construction_toolkit/files',
'altname' : 'SCT',
},
{
'root' : '_/googleclient/tools/hammer',
'altname' : 'HAMMER',
},
],
# List of rules, applied in order.
'rules' : [
# Each rule is a dict.
# * It must contaihn a 'regexp' entry. Filenames which match this
# regular expression (after applying mappings from 'roots') are
# affected by the rule.
#
# * Other entries in the dict are attributes to apply to matching files.
#
# Allowed attributes:
#
# 'include' : If 1, the file will be included in coverage reports. If 0,
# it won't be included in coverage reports.
#
# 'group' : Name of the group the file belongs to. The most common
# group names are 'source' and 'test'. Files must belong to
# a group to be included in coverage reports.
#
# 'language' : Programming language for the file. The most common
# languages are 'C', 'C++', 'python', 'ObjC', 'ObjC++'.
# Files must have a language to be included in coverage
# reports.
#
# 'add_if_missing' : If 1, and the file was not referenced by any LCOV
# files, it will be be scanned for executable lines
# and added to the coverage report. If 0, if the
# file is not referenced by any LCOV files, it will
# simply be ignored and not present in coverage
# reports.
# Files/paths to include
{
'regexp' : '^(SCT|HAMMER)/',
'include' : 1,
'add_if_missing': 1,
},
{
'regexp' : '.*/(\\.svn|\\.hg)/',
'include' : 0,
},
# Groups
{
'regexp' : '',
'group' : 'source',
},
{
'regexp' : '.*_(test|test_mac|unittest)\\.',
'group' : 'test',
},
# Languages
{
'regexp' : '.*\\.py$',
'language' : 'python',
},
],
# List of paths to add source from.
#
# Each entry is a path. It may be a local path, or one relative to a root
# altname (see 'roots' above).
#
# If more than one root's altname matches the start of this path, all matches
# will be attempted; matches where the candidate directory doesn't exist will
# be ignored. For example, if you're combining data from multiple platforms'
# LCOV files, you probably defined at least one root per LCOV, but only have
# one copy of the source on your local platform. That's fine; Croc will use
# the source it can find and not worry about the source it can't.
#
# Source files must be added via 'add_files' to generate line-by-line HTML
# output (via the --html option) and/or to scan for missing executable lines
# (if 'add_if_missing' is 1).
'add_files' : [
'SCT',
'HAMMER',
],
# Statistics to print.
#
'print_stats' : [
# Each entry is a dict.
#
# It must have a 'stat' entry, which is the statistic to print. This may
# be one of the following stats:
#
# * files_executable
# * files_instrumented
# * files_covered
# * lines_executable
# * lines_instrumented
# * lines_covered
#
# or an expression using those stats.
#
# It may have a 'format' entry, which is a python formatting string (very
# printf-like) for the statistic.
#
# It may have a 'group' entry. If this is specified, only files from the
# matching group will be included in the statistic. If not specified, the
# group defaults to 'all', which means all groups.
{
'stat' : 'files_executable',
'format' : '*RESULT FilesKnown: files_executable= %d files',
},
{
'stat' : 'files_instrumented',
'format' : '*RESULT FilesInstrumented: files_instrumented= %d files',
},
{
'stat' : '100.0 * files_instrumented / files_executable',
'format' : '*RESULT FilesInstrumentedPercent: files_instrumented_percent= %g',
},
{
'stat' : 'lines_instrumented',
'format' : '*RESULT LinesInstrumented: lines_instrumented= %d lines',
},
{
'stat' : 'lines_covered',
'format' : '*RESULT LinesCoveredSource: lines_covered_source= %d lines',
'group' : 'source',
},
{
'stat' : 'lines_covered',
'format' : '*RESULT LinesCoveredTest: lines_covered_test= %d lines',
'group' : 'test',
},
],
}
|