Declare libdconf_service as a dependency
[dconf.git] / trim-lcov.py
blobc1709c3c8554346d3f5c7571ff6a22963b03d551
1 #!/usr/bin/python
3 # This script removes branch and/or line coverage data for lines that
4 # contain a particular substring.
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).
11 # This script intentionally avoids checking for errors. Any exceptions
12 # will trigger make to fail.
14 # Author: Ryan Lortie <desrt@desrt.ca>
16 import sys
18 line_suppress = ['g_assert_not_reached']
19 branch_suppress = ['g_assert', 'g_return_if_fail', 'g_return_val_if_fail', 'G_DEFINE_TYPE']
21 def check_suppress(suppressions, source, data):
22 line, _, rest = data.partition(',')
23 line = int(line) - 1
25 assert line < len(source)
27 for suppression in suppressions:
28 if suppression in source[line]:
29 return True
31 return False
33 source = []
34 for line in sys.stdin:
35 line = line[:-1]
37 keyword, _, rest = line.partition(':')
39 # Source file
40 if keyword == 'SF':
41 source = file(rest).readlines()
43 # Branch coverage data
44 elif keyword == 'BRDA':
45 if check_suppress(branch_suppress, source, rest):
46 continue
48 # Line coverage data
49 elif keyword == 'DA':
50 if check_suppress(line_suppress, source, rest):
51 continue
53 print line