Home | History | Annotate | Download | only in code_coverage
      1 # -*- python -*-
      2 
      3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 # Example configuration file for Croc
      8 
      9 # Basic formatting rules:
     10 #   * It looks like JSON.
     11 #   * It's really python.
     12 #   * Dictionaries are wrapped in {}.  Order does not matter.  Entries are of
     13 #     the form:
     14 #         'key':value,
     15 #     Note the trailing comma, which will help save you from python's built-in
     16 #     string concatenation.
     17 #   * Lists are wrapped in [].  Order does matter.  Entries should be followed
     18 #     with a trailing comma, which will help save you from python's built-in
     19 #     string concatenation.
     20 #   * Comments start with # and extend to end of line.
     21 #   * Strings are wrapped in ''.  Backslashes must be escaped ('foo\\bar', not
     22 #     'foo\bar') - this is particularly important in rule regular expressions.
     23 
     24 
     25 # What follows is the main configuration dictionary.
     26 {
     27   # List of root directories, applied in order.
     28   #
     29   # Typically, coverage data files contain absolute paths to the sources.
     30   # What you care about is usually a relative path from the top of your source
     31   # tree (referred to here as a 'source root') to the sources.
     32   #
     33   # Roots may also be specified on the command line via the --root option.
     34   # Roots specified by --root are applied before those specified in config
     35   # files.
     36   'roots' : [
     37     # Each entry is a dict.
     38     #     * It must contain a 'root' entry, which is the start of a path.
     39     #         * Root entries may be absolute paths
     40     #         * Root entries starting with './' or '../' are relative paths, and
     41     #           are taken relative to the current directory where you run croc.
     42     #         * Root entries may start with previously defined altnames.
     43     #         * Use '/' as a path separator, even on Windows.
     44     #     * It may contain a 'altname' entry.  If the root matches the start of
     45     #        a filename, that start is replaced with the 'altname', or with '_'
     46     #        if no default is specified.
     47     #     * Multiple root entries may share the same altname.  This is commonly
     48     #       used when combining LCOV files from different platforms into one
     49     #       coverage report, when each platform checks out source code into a
     50     #       different source tree.
     51     {'root' : 'c:/P4/EarthHammer'},
     52     {'root' : 'd:/pulse/recipes/330137642/base'},
     53     {'root' : '/Volumes/BuildData/PulseData/data/recipes/330137640/base'},
     54     {'root' : '/usr/local/google/builder/.pulse-agent/data/recipes/330137641/base'},
     55 
     56     # Sub-paths we specifically care about and want to call out.  Note that
     57     # these are relative to the default '_' altname.
     58     {
     59       'root' : '_/googleclient/third_party/software_construction_toolkit/files',
     60       'altname' : 'SCT',
     61     },
     62     {
     63       'root' : '_/googleclient/tools/hammer',
     64       'altname' : 'HAMMER',
     65     },
     66   ],
     67 
     68   # List of rules, applied in order.
     69   'rules' : [
     70     # Each rule is a dict.
     71     #   * It must contaihn a 'regexp' entry.  Filenames which match this
     72     #     regular expression (after applying mappings from 'roots') are
     73     #     affected by the rule.
     74     #
     75     #   * Other entries in the dict are attributes to apply to matching files.
     76     #
     77     # Allowed attributes:
     78     #
     79     #   'include' : If 1, the file will be included in coverage reports.  If 0,
     80     #               it won't be included in coverage reports.
     81     #
     82     #   'group' : Name of the group the file belongs to.  The most common
     83     #             group names are 'source' and 'test'.  Files must belong to
     84     #             a group to be included in coverage reports.
     85     #
     86     #   'language' : Programming language for the file.  The most common
     87     #                languages are 'C', 'C++', 'python', 'ObjC', 'ObjC++'.
     88     #                Files must have a language to be included in coverage
     89     #                reports.
     90     #
     91     #   'add_if_missing' : If 1, and the file was not referenced by any LCOV
     92     #                      files, it will be be scanned for executable lines
     93     #                      and added to the coverage report.  If 0, if the
     94     #                      file is not referenced by any LCOV files, it will
     95     #                      simply be ignored and not present in coverage
     96     #                      reports.
     97 
     98     # Files/paths to include
     99     {
    100       'regexp' : '^(SCT|HAMMER)/',
    101       'include' : 1,
    102       'add_if_missing': 1,
    103     },
    104     {
    105       'regexp' : '.*/(\\.svn|\\.hg)/',
    106       'include' : 0,
    107     },
    108 
    109     # Groups
    110     {
    111       'regexp' : '',
    112       'group' : 'source',
    113     },
    114     {
    115       'regexp' : '.*_(test|test_mac|unittest)\\.',
    116       'group' : 'test',
    117     },
    118 
    119     # Languages
    120     {
    121       'regexp' : '.*\\.py$',
    122       'language' : 'python',
    123     },
    124   ],
    125 
    126   # List of paths to add source from.
    127   #
    128   # Each entry is a path.  It may be a local path, or one relative to a root
    129   # altname (see 'roots' above).
    130   #
    131   # If more than one root's altname matches the start of this path, all matches
    132   # will be attempted; matches where the candidate directory doesn't exist will
    133   # be ignored.  For example, if you're combining data from multiple platforms'
    134   # LCOV files, you probably defined at least one root per LCOV, but only have
    135   # one copy of the source on your local platform.  That's fine; Croc will use
    136   # the source it can find and not worry about the source it can't.
    137   #
    138   # Source files must be added via 'add_files' to generate line-by-line HTML
    139   # output (via the --html option) and/or to scan for missing executable lines
    140   # (if 'add_if_missing' is 1).
    141   'add_files' : [
    142     'SCT',
    143     'HAMMER',
    144   ],
    145 
    146   # Statistics to print.
    147   #
    148   'print_stats' : [
    149     # Each entry is a dict.
    150     #
    151     # It must have a 'stat' entry, which is the statistic to print.  This may
    152     # be one of the following stats:
    153     #
    154     #   * files_executable
    155     #   * files_instrumented
    156     #   * files_covered
    157     #   * lines_executable
    158     #   * lines_instrumented
    159     #   * lines_covered
    160     #
    161     # or an expression using those stats.
    162     #
    163     # It may have a 'format' entry, which is a python formatting string (very
    164     # printf-like) for the statistic.
    165     #
    166     # It may have a 'group' entry.  If this is specified, only files from the
    167     # matching group will be included in the statistic.  If not specified, the
    168     # group defaults to 'all', which means all groups.
    169     {
    170       'stat' : 'files_executable',
    171       'format' : '*RESULT FilesKnown: files_executable= %d files',
    172     },
    173     {
    174       'stat' : 'files_instrumented',
    175       'format' : '*RESULT FilesInstrumented: files_instrumented= %d files',
    176     },
    177     {
    178       'stat' : '100.0 * files_instrumented / files_executable',
    179       'format' : '*RESULT FilesInstrumentedPercent: files_instrumented_percent= %g',
    180     },
    181     {
    182       'stat' : 'lines_instrumented',
    183       'format' : '*RESULT LinesInstrumented: lines_instrumented= %d lines',
    184     },
    185     {
    186       'stat' : 'lines_covered',
    187       'format' : '*RESULT LinesCoveredSource: lines_covered_source= %d lines',
    188       'group' : 'source',
    189     },
    190     {
    191       'stat' : 'lines_covered',
    192       'format' : '*RESULT LinesCoveredTest: lines_covered_test= %d lines',
    193       'group' : 'test',
    194     },
    195   ],
    196 
    197 }
    198