Merge lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/lcov-plugin-fix into lp://qastaging/drizzle-automation

Proposed by Lee Bieber
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/lcov-plugin-fix
Merge into: lp://qastaging/drizzle-automation
Diff against target: 123 lines (+71/-16)
1 file modified
drizzle/automation/lcov/run.py (+71/-16)
To merge this branch: bzr merge lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/lcov-plugin-fix
Reviewer Review Type Date Requested Status
Jay Pipes Approve
Review via email: mp+17397@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

fix lcov to properly get plugin percent coverage. Since the is no plugin/index.hml file we need to go through and find all the plugin/*/index.html files and add up the numbers and then divide by the number of index.html files found to get a proper coverage number.

Revision history for this message
Jay Pipes (jaypipes) wrote :

Excellent work.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzle/automation/lcov/run.py'
2--- drizzle/automation/lcov/run.py 2010-01-05 19:23:09 +0000
3+++ drizzle/automation/lcov/run.py 2010-01-14 17:40:22 +0000
4@@ -28,11 +28,72 @@
5
6 import sys
7 import os
8+import re
9 import os.path
10 from drizzle.automation.lib import logging
11 import commands
12 import datetime
13
14+# in the lcov/index.html file look for the total percentage of the
15+# top level directories (drizzled, client), except plugin which is processed differently
16+def find_coverage_percentage(dir, file_name):
17+ fileHandle= open(file_name).read()
18+ pattern= "href=\"%s/index.html\"" % dir
19+ pos= fileHandle.find(pattern)
20+
21+ if pos > 0:
22+ float_pattern= "alt=\""
23+ new_pos= fileHandle.find(float_pattern, pos)
24+ if new_pos:
25+ new_pos= new_pos + 5 # length of alt="
26+ end_pos= new_pos + 1
27+ while fileHandle[end_pos].isdigit() or fileHandle[end_pos] == '.':
28+ end_pos= end_pos + 1
29+ percentage= float(fileHandle[new_pos:end_pos])
30+ else:
31+ percentage= 0.0
32+
33+ #fileHandle.close()
34+ return percentage
35+
36+# Because plugin does not have files in its root directory
37+# we need to find all the index.html files in the plugin
38+# directory and get the percent coverage for each and
39+# add to a grand total divided by total count of plugin index.html files
40+def find_coverage_percentage_for_plugin_dir(file_name):
41+ fileHandle= open(file_name)
42+ pattern= re.compile('href="plugin/\w+/*\w*/index.html"')
43+ float_pattern= re.compile('alt="')
44+
45+ inlines= fileHandle.readlines()
46+ found= 0
47+ counter=0
48+ total=0
49+ for inline in inlines:
50+ # first find a line to matches pattern, which will be something like:
51+ # href="plugin/ascii/index.html
52+ if not found:
53+ first_pos= pattern.search(inline)
54+ if (first_pos):
55+ found= 1
56+ # once we have found pattern, now get the next line that has float_pattern
57+ # and look for the percent coverage number for this plugin directory
58+ # it is found right after the float_pattern
59+ if found:
60+ next_pattern= float_pattern.search(inline)
61+ if (next_pattern):
62+ begin_position = next_pattern.end()
63+ end_position = begin_position + 1
64+ while inline[end_position].isdigit() or inline[end_position] == '.':
65+ end_position= end_position + 1
66+ dir_percent= float(inline[begin_position:end_position])
67+ total= total + dir_percent
68+ counter = counter + 1
69+ found= 0
70+
71+ fileHandle.close()
72+ return total/counter
73+
74 # print out failing tests if we encounter test failures
75 def check_test_suite_logs():
76 infilename= "tests/var/log/drizzle-test-run.log"
77@@ -83,7 +144,7 @@
78 outf.close()
79 os.rename(outfilename, infilename)
80
81-# Need to munge the string for some files in the plugin directory
82+# Need to munge the string for some files in the plugin and drizzled directory
83 # as gcov can't find the source file and thus assumes incorrectly
84 # that it is in the root directory. So we need to add the missing path
85 # to the directory string
86@@ -243,24 +304,16 @@
87 lcov_dirs= variables['lcov']['directories'].split(',')
88
89 # Grab our index file for the lcov reports
90- index_file_contents= open("%s/%s/index.html" % (working_dir, output_dir)).read()
91 for dir in lcov_dirs:
92
93- pattern= "href=\"%s/index.html\"" % dir
94- pos= index_file_contents.find(pattern)
95-
96- if pos > 0:
97- float_pattern= "alt=\""
98- new_pos= index_file_contents.find(float_pattern, pos)
99- if new_pos:
100- new_pos= new_pos + 5 # length of alt="
101- end_pos= new_pos + 1
102- while index_file_contents[end_pos].isdigit() or index_file_contents[end_pos] == '.':
103- end_pos= end_pos + 1
104- dir_percent= float(index_file_contents[new_pos:end_pos])
105- percentages[dir]= dir_percent
106+ file_name= "%s/%s/index.html" % (working_dir, output_dir)
107+ # in the lcov/index.html file look for the total percentage of the
108+ # top level directories (drizzled, client), except plugin which is processed differently
109+ # since there are multiple entries in the file for plugin percentages
110+ if dir == 'plugin':
111+ percentages[dir]= find_coverage_percentage_for_plugin_dir(file_name)
112 else:
113- percentages[dir]= 0.0
114+ percentages[dir]= find_coverage_percentage(dir, file_name)
115
116 # Insert into the DB...
117 for dir in lcov_dirs:
118@@ -273,3 +326,5 @@
119 db.execute_sql(sql)
120
121 return True
122+
123+

Subscribers

People subscribed via source and target branches

to all changes: