~ps-jenkins/indicator-transfer/ubuntu-vivid-proposed

1.1.19 by Charles Kerr
get the test coverage reports working
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