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
=== modified file 'drizzle/automation/lcov/run.py'
--- drizzle/automation/lcov/run.py 2010-01-05 19:23:09 +0000
+++ drizzle/automation/lcov/run.py 2010-01-14 17:40:22 +0000
@@ -28,11 +28,72 @@
2828
29import sys29import sys
30import os30import os
31import re
31import os.path32import os.path
32from drizzle.automation.lib import logging33from drizzle.automation.lib import logging
33import commands34import commands
34import datetime35import datetime
3536
37# in the lcov/index.html file look for the total percentage of the
38# top level directories (drizzled, client), except plugin which is processed differently
39def find_coverage_percentage(dir, file_name):
40 fileHandle= open(file_name).read()
41 pattern= "href=\"%s/index.html\"" % dir
42 pos= fileHandle.find(pattern)
43
44 if pos > 0:
45 float_pattern= "alt=\""
46 new_pos= fileHandle.find(float_pattern, pos)
47 if new_pos:
48 new_pos= new_pos + 5 # length of alt="
49 end_pos= new_pos + 1
50 while fileHandle[end_pos].isdigit() or fileHandle[end_pos] == '.':
51 end_pos= end_pos + 1
52 percentage= float(fileHandle[new_pos:end_pos])
53 else:
54 percentage= 0.0
55
56 #fileHandle.close()
57 return percentage
58
59# Because plugin does not have files in its root directory
60# we need to find all the index.html files in the plugin
61# directory and get the percent coverage for each and
62# add to a grand total divided by total count of plugin index.html files
63def find_coverage_percentage_for_plugin_dir(file_name):
64 fileHandle= open(file_name)
65 pattern= re.compile('href="plugin/\w+/*\w*/index.html"')
66 float_pattern= re.compile('alt="')
67
68 inlines= fileHandle.readlines()
69 found= 0
70 counter=0
71 total=0
72 for inline in inlines:
73 # first find a line to matches pattern, which will be something like:
74 # href="plugin/ascii/index.html
75 if not found:
76 first_pos= pattern.search(inline)
77 if (first_pos):
78 found= 1
79 # once we have found pattern, now get the next line that has float_pattern
80 # and look for the percent coverage number for this plugin directory
81 # it is found right after the float_pattern
82 if found:
83 next_pattern= float_pattern.search(inline)
84 if (next_pattern):
85 begin_position = next_pattern.end()
86 end_position = begin_position + 1
87 while inline[end_position].isdigit() or inline[end_position] == '.':
88 end_position= end_position + 1
89 dir_percent= float(inline[begin_position:end_position])
90 total= total + dir_percent
91 counter = counter + 1
92 found= 0
93
94 fileHandle.close()
95 return total/counter
96
36# print out failing tests if we encounter test failures97# print out failing tests if we encounter test failures
37def check_test_suite_logs():98def check_test_suite_logs():
38 infilename= "tests/var/log/drizzle-test-run.log"99 infilename= "tests/var/log/drizzle-test-run.log"
@@ -83,7 +144,7 @@
83 outf.close()144 outf.close()
84 os.rename(outfilename, infilename)145 os.rename(outfilename, infilename)
85146
86# Need to munge the string for some files in the plugin directory147# Need to munge the string for some files in the plugin and drizzled directory
87# as gcov can't find the source file and thus assumes incorrectly148# as gcov can't find the source file and thus assumes incorrectly
88# that it is in the root directory. So we need to add the missing path149# that it is in the root directory. So we need to add the missing path
89# to the directory string150# to the directory string
@@ -243,24 +304,16 @@
243 lcov_dirs= variables['lcov']['directories'].split(',')304 lcov_dirs= variables['lcov']['directories'].split(',')
244305
245 # Grab our index file for the lcov reports306 # Grab our index file for the lcov reports
246 index_file_contents= open("%s/%s/index.html" % (working_dir, output_dir)).read()
247 for dir in lcov_dirs:307 for dir in lcov_dirs:
248308
249 pattern= "href=\"%s/index.html\"" % dir309 file_name= "%s/%s/index.html" % (working_dir, output_dir)
250 pos= index_file_contents.find(pattern)310 # in the lcov/index.html file look for the total percentage of the
251 311 # top level directories (drizzled, client), except plugin which is processed differently
252 if pos > 0:312 # since there are multiple entries in the file for plugin percentages
253 float_pattern= "alt=\""313 if dir == 'plugin':
254 new_pos= index_file_contents.find(float_pattern, pos)314 percentages[dir]= find_coverage_percentage_for_plugin_dir(file_name)
255 if new_pos:
256 new_pos= new_pos + 5 # length of alt="
257 end_pos= new_pos + 1
258 while index_file_contents[end_pos].isdigit() or index_file_contents[end_pos] == '.':
259 end_pos= end_pos + 1
260 dir_percent= float(index_file_contents[new_pos:end_pos])
261 percentages[dir]= dir_percent
262 else:315 else:
263 percentages[dir]= 0.0316 percentages[dir]= find_coverage_percentage(dir, file_name)
264317
265 # Insert into the DB...318 # Insert into the DB...
266 for dir in lcov_dirs:319 for dir in lcov_dirs:
@@ -273,3 +326,5 @@
273 db.execute_sql(sql)326 db.execute_sql(sql)
274327
275 return True328 return True
329
330

Subscribers

People subscribed via source and target branches

to all changes: