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

Proposed by Lee Bieber
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/update-lcov
Merge into: lp://qastaging/drizzle-automation
Diff against target: 233 lines (+35/-99)
2 files modified
drizzle/automation/config/automation.cnf (+2/-2)
drizzle/automation/lcov/run.py (+33/-97)
To merge this branch: bzr merge lp://qastaging/~kalebral-deactivatedaccount/drizzle-automation/update-lcov
Reviewer Review Type Date Requested Status
Jay Pipes Approve
Review via email: mp+16860@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

Changes to get lcov working again. Per input from Patrick Crews, don't process directories individually, process as one.

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

One tiny thing needs to be fixed. Other than that, looks good :)

497 - logging.error("Failed to generate LCOV HTML coverage report. Got error: %s" % output)
498 + logging.error("Failed to generate LCOV HTML coverage report. Got error after running %s" % (cmd,output))

Note that there is an incorrect number of placeholders in line 498's format string. You probably meant to put "Failed to generate LCOV HTML coverage report. Got error %s after running %s" % (output, cmd)

review: Needs Fixing
131. By lbieber <lbieber@orisndriz01>

had incorrect number of arguments when logging error

Revision history for this message
Jay Pipes (jaypipes) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzle/automation/config/automation.cnf'
2--- drizzle/automation/config/automation.cnf 2009-12-22 21:04:47 +0000
3+++ drizzle/automation/config/automation.cnf 2010-01-05 19:26:14 +0000
4@@ -90,7 +90,7 @@
5
6 # Directories queried during GCOV/LCOV code coverage
7
8-directories= drizzled,mysys,mystrings
9+directories= client,drizzled,plugin
10
11 [randgen]
12 # location of the Random Query Generator repository
13@@ -133,5 +133,5 @@
14
15 # Directories queried during SLOCcount processing
16
17-directories= drizzled,mysys,mystrings
18+directories= client,drizzled,plugin
19
20
21=== modified file 'drizzle/automation/lcov/run.py'
22--- drizzle/automation/lcov/run.py 2009-10-02 15:29:34 +0000
23+++ drizzle/automation/lcov/run.py 2010-01-05 19:26:14 +0000
24@@ -52,7 +52,7 @@
25 inf.close()
26
27 # Strip out include files that we are not interested in
28-def strip_include_files(working_dir):
29+def strip_include_files(working_dir, infilename):
30 logging.info("Stripping LCOV files of unwanted includes.")
31 ignore_patterns= [
32 'SF:/usr/include/c++'
33@@ -60,9 +60,7 @@
34 , 'SF:/usr/include/google/protobuf'
35 , 'SF:/usr/include/security'
36 ]
37- os.chdir("%s/lcov" % working_dir)
38 outfilename= "all.out.new"
39- infilename= "all.out"
40 inf= open(infilename, "r+b")
41 outf= open(outfilename, "w+b")
42
43@@ -85,52 +83,11 @@
44 outf.close()
45 os.rename(outfilename, infilename)
46
47-# (ugly) hack to get output to show correctly
48-# walk the drizzle source directory and get a list of files in the .libs directory
49-# then move the .gcda and .gcno files up one level
50-def move_lcov_files(working_dir):
51- import distutils.file_util
52- logging.info("Moving .gcda and .gcno files from .libs directory up one directory level")
53- for root,dirs,files in os.walk(working_dir, topdown=True):
54- for d in dirs:
55- if d == '.libs':
56- dir= os.path.join("%s/%s" % (root,d))
57- for next_root,next_dirs,next_files in os.walk(dir, topdown=True):
58- for f in next_files:
59- file= os.path.join("%s/%s" % (dir,f))
60- # now find .gcda or .gcno files
61- if file.endswith(".gcda") or file.endswith(".gcno"):
62- upper_dir = os.path.dirname(dir)
63- # then move them up one level in the directory tree
64- #logging.info("Moving %s to %s" % (file,upper_dir))
65- distutils.file_util.move_file(file,upper_dir)
66-
67-# ugly hack #2
68-# need to munge the string for some files in the plugin and drizzled directory
69+# Need to munge the string for some files in the plugin directory
70 # as gcov can't find the source file and thus assumes incorrectly
71 # that it is in the root directory. So we need to add the missing path
72 # to the directory string
73-def patch_drizzled(working_dir):
74- # this is the missing string
75- working_dir2= os.path.dirname(working_dir)
76- # this is what they look like before
77- bad_strings= [
78- 'SF:' + working_dir + '/drizzled/replication.pb.h'
79- ,'SF:' + working_dir2 + '/drizzled/message/replication.pb.h'
80- ,'SF:' + working_dir + '/drizzled/table.pb.h'
81- ,'SF:' + working_dir2 + '/drizzled/message/table.pb.h'
82- ]
83-
84- # this is what they need to look like afterwards
85- patch_strings= [
86- 'SF:' + working_dir + '/drizzled/message/replication.pb.h'
87- ,'SF:' + working_dir + '/drizzled/message/replication.pb.h'
88- ,'SF:' + working_dir + '/drizzled/message/table.pb.h'
89- ,'SF:' + working_dir + '/drizzled/message/table.pb.h'
90- ]
91- patch_file_strings(working_dir, bad_strings, patch_strings, './drizzled/drizzled.out')
92-
93-def patch_plugin(working_dir):
94+def patch_files(working_dir, output_file):
95 # this is the missing string
96 add_dir_string= 'plugin/innobase/pars'
97 # this is what they look like before
98@@ -139,6 +96,8 @@
99 ,'SF:' + working_dir + '/pars0grm.c'
100 ,'SF:' + working_dir + '/pars0grm.y'
101 ,'SF:' + working_dir + '/pars0lex.l'
102+ ,'SF:' + working_dir + '/sql_yacc.cc'
103+ ,'SF:' + working_dir + '/sql_yacc.yy'
104 ]
105
106 # this is what they need to look like afterwards
107@@ -147,11 +106,12 @@
108 ,'SF:' + working_dir + '/' + add_dir_string + '/pars0grm.c'
109 ,'SF:' + working_dir + '/' + add_dir_string + '/pars0grm.y'
110 ,'SF:' + working_dir + '/' + add_dir_string + '/pars0lex.l'
111+ ,'SF:' + working_dir + '/' + 'drizzled' + '/sql_yacc.cc'
112+ ,'SF:' + working_dir + '/' + 'drizzled' + '/sql_yacc.yy'
113 ]
114- patch_file_strings(working_dir, bad_strings, patch_strings, './plugin/plugin.out')
115+ patch_file_strings(working_dir, bad_strings, patch_strings, output_file)
116
117 def patch_file_strings(working_dir, bad_strings, patch_strings, infilename):
118- os.chdir(working_dir)
119 outfilename= "/tmp/lcov.tmp"
120 inf= open(infilename, "r+b")
121 outf= open(outfilename, "w+b")
122@@ -182,9 +142,6 @@
123
124 os.chdir(working_dir)
125
126- # Set of directories we're interested in running coverage reports on
127- lcov_dirs= variables['lcov']['directories'].split(',')
128-
129 # For BZR mode, the "version" of the server (used in identifying the
130 # command run when logging to the database) is the branch and revision number.
131 #
132@@ -198,12 +155,11 @@
133 # Reset all coverage counters
134 logging.info("Resetting all LCOV coverage counters.")
135
136- for dir in lcov_dirs:
137- cmd= "lcov --directory %s/%s --zerocounters" % (working_dir, dir)
138- (retcode, output)= commands.getstatusoutput(cmd)
139- if not retcode == 0:
140- logging.error("Failed to zero-out coverage counters for %s/%s. Exiting." % (working_dir, dir))
141- sys.exit(1)
142+ cmd= "lcov --directory %s --zerocounters" % (working_dir)
143+ (retcode, output)= commands.getstatusoutput(cmd)
144+ if not retcode == 0:
145+ logging.error("Failed to zero-out coverage counters for %s. Exiting." % (working_dir))
146+ sys.exit(1)
147
148 # Depending on the type of server we are testing/processing, we may
149 # instantiate a "Builder" object, which is used to build the
150@@ -238,54 +194,31 @@
151 check_test_suite_logs()
152 sys.exit(1)
153
154- # Produce coverage info files
155- logging.info("Producing LCOV info files for all directories.")
156+ # Produce coverage info file
157+ logging.info("Producing LCOV info file.")
158
159- # move lcov file out of .libs directory before capturing lcov info
160- move_lcov_files(working_dir)
161-
162- for dir in lcov_dirs:
163- # special case drizzled's --base-directory
164- if dir == 'drizzled':
165- base_dir= '.'
166- else:
167- base_dir= '..'
168- logging.info("Processing %s with base-directory set to %s" % (dir,base_dir));
169- cmd= "cd %s/%s; lcov --capture --directory . --base-directory %s --output-file %s.out" % (working_dir, dir, base_dir, dir.replace(os.path.sep, '.'))
170- (retcode, output)= commands.getstatusoutput(cmd)
171- if not retcode == 0:
172- logging.error("Failed to capture LCOV data for %s/%s. Exiting." % (working_dir, dir))
173- sys.exit(1)
174- if dir == 'plugin':
175- patch_plugin(working_dir)
176- elif dir == 'drizzled':
177- patch_drizzled(working_dir)
178-
179- os.chdir(working_dir)
180- logging.info("Aggregating LCOV info files")
181- cmds= ["rm -rf lcov && mkdir -p lcov && lcov"]
182- cmds= cmds + [
183- "-a %s/%s/%s.out" % (working_dir, dir, dir.replace(os.path.sep, "."))
184- for dir in lcov_dirs
185- ]
186- cmds= cmds + ["-o lcov/all.out"]
187- cmd= " ".join(cmds)
188-
189+ output_file= "drizzle_lcov.info"
190+ cmd= "lcov --capture --directory %s --base-directory %s --output-file %s" % (working_dir, working_dir, output_file)
191 (retcode, output)= commands.getstatusoutput(cmd)
192-
193 if not retcode == 0:
194- logging.error("Failed to aggregate LCOV files. Got error: %s" % output)
195+ logging.error("Failed to capture LCOV data. Exiting.")
196 sys.exit(1)
197-
198- strip_include_files(working_dir)
199- os.chdir(working_dir)
200+ patch_files(working_dir, output_file)
201+
202+ # remove the lcov output directory if it exists
203+ output_dir="lcov"
204+ if os.path.exists(output_dir):
205+ import shutil
206+ shutil.rmtree(output_dir)
207+
208+ strip_include_files(working_dir, output_file)
209
210 # Produce HTML coverage reports
211 logging.info("Producing LCOV HTML coverage reports.")
212
213- (retcode, output)= commands.getstatusoutput("genhtml -o lcov lcov/all.out")
214+ (retcode, output)= commands.getstatusoutput("genhtml -o %s %s" % (output_dir, output_file))
215 if not retcode == 0:
216- logging.error("Failed to generate LCOV HTML coverage report. Got error: %s" % output)
217+ logging.error("Failed to generate LCOV HTML coverage report. Got error %s after running %s" % (output, cmd))
218 sys.exit(1)
219
220 if variables['no_rsync'] is False:
221@@ -306,8 +239,11 @@
222 # Scrape the percentages...
223 percentages= {}
224
225+ # Set of directories we're interested in running coverage reports on
226+ lcov_dirs= variables['lcov']['directories'].split(',')
227+
228 # Grab our index file for the lcov reports
229- index_file_contents= open("%s/lcov/index.html" % working_dir).read()
230+ index_file_contents= open("%s/%s/index.html" % (working_dir, output_dir)).read()
231 for dir in lcov_dirs:
232
233 pattern= "href=\"%s/index.html\"" % dir

Subscribers

People subscribed via source and target branches

to all changes: