~ci-train-bot/indicator-session/indicator-session-ubuntu-zesty-2565

« back to all changes in this revision

Viewing changes to trim-lcov.py

  • Committer: Bileto Bot
  • Author(s): Rodney Dawes
  • Date: 2017-02-10 17:08:42 UTC
  • mfrom: (479.2.3 fix-coverage)
  • Revision ID: ci-train-bot@canonical.com-20170210170842-j85h81qg1uxkk3oi
Use coverage support from cmake-extras.

Approved by: Pete Woods, unity-api-1-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
# This script removes branch and/or line coverage data for lines that
4
 
# contain a particular substring.
5
 
#
6
 
# In the interest of "fairness" it removes all branch or coverage data
7
 
# when a match is found -- not just negative data.  It is therefore
8
 
# likely that running this script will actually reduce the total number
9
 
# of lines and branches that are marked as covered (in absolute terms).
10
 
#
11
 
# This script intentionally avoids checking for errors.  Any exceptions
12
 
# will trigger make to fail.
13
 
#
14
 
# Author: Ryan Lortie <desrt@desrt.ca>
15
 
 
16
 
import sys
17
 
 
18
 
line_suppress = ['g_assert_not_reached']
19
 
branch_suppress = ['g_assert', 'g_return_if_fail', 'g_clear_object', 'g_clear_pointer', 'g_return_val_if_fail', 'G_DEFINE_TYPE']
20
 
 
21
 
def check_suppress(suppressions, source, data):
22
 
    line, _, rest = data.partition(',')
23
 
    line = int(line) - 1
24
 
 
25
 
    assert line < len(source)
26
 
 
27
 
    for suppression in suppressions:
28
 
        if suppression in source[line]:
29
 
            return True
30
 
 
31
 
    return False
32
 
 
33
 
source = []
34
 
for line in sys.stdin:
35
 
    line = line[:-1]
36
 
 
37
 
    keyword, _, rest = line.partition(':')
38
 
 
39
 
    # Source file
40
 
    if keyword == 'SF':
41
 
        source = file(rest).readlines()
42
 
 
43
 
    # Branch coverage data
44
 
    elif keyword == 'BRDA':
45
 
        if check_suppress(branch_suppress, source, rest):
46
 
            continue
47
 
 
48
 
    # Line coverage data
49
 
    elif keyword == 'DA':
50
 
        if check_suppress(line_suppress, source, rest):
51
 
            continue
52
 
 
53
 
    print line