Changeset 53eafd97a7caf432dce29b625005d7e028ae5b62
- Timestamp:
- 04/27/08 11:38:01 (8 months ago)
- Author:
- David Balmain <dbalmain@…>
- Parents:
- 340bd709cb5031fcc12fc5f7d3fae191ec716b7c
- Children:
- 190f7af639412f6d6b91876cb6b9f609028b7e46
- git-committer:
- David Balmain <dbalmain@gmail.com> / 2008-04-27T11:38:01Z+1000
- Message:
-
Added gcov history plotting and publishing.
Can now plot history of gcov coverage and publish results to Ferret's trac wiki
- Location:
- c
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r340bd7
|
r53eafd
|
|
| 55 | 55 | sh script |
| 56 | 56 | end |
| | 57 | |
| | 58 | ### |
| | 59 | # Useful Constants |
| | 60 | ### |
| | 61 | |
| | 62 | DAY = 24 * 60 * 60 # seconds in day |
| 57 | 63 | |
| 58 | 64 | ### |
| … |
… |
|
| 179 | 185 | if copts != old_copts |
| 180 | 186 | File.open(copts_file, 'w') {|f| f.write(Marshal.dump(copts))} |
| 181 | | Rake::Task[:clean].invoke |
| | 187 | Rake::Task[:scrub].invoke |
| 182 | 188 | end |
| 183 | 189 | end |
| … |
… |
|
| 197 | 203 | '*.gcov', |
| 198 | 204 | 'y.tab.c']) |
| 199 | | |
| 200 | 205 | CLOBBER.include([ '*.a', |
| 201 | 206 | '**/*.o', |
| … |
… |
|
| 207 | 212 | GCOV_DIR]) |
| 208 | 213 | |
| 209 | | task :default => :testall |
| 210 | | |
| | 214 | SCRUB = FileList[CLEAN, '**/*.o'] |
| | 215 | desc "clean for rebuild" |
| | 216 | task :scrub do |
| | 217 | SCRUB.each {|fn| rm_r fn rescue nil} |
| | 218 | end |
| | 219 | |
| | 220 | ### |
| | 221 | # Test Helpers |
| | 222 | ### |
| 211 | 223 | def run_tests |
| 212 | 224 | check_coptions |
| … |
… |
|
| 221 | 233 | FileList['.rake/HAVE_*'].each {|fn| CFLAGS << File.read(fn)} |
| 222 | 234 | end |
| | 235 | |
| | 236 | ### |
| | 237 | # gcov Helpers |
| | 238 | ### |
| | 239 | GCOV_HIST_FILE = ".rake/gcov.history" |
| | 240 | def load_gcov_history |
| | 241 | Marshal.load(File.read(GCOV_HIST_FILE)) |
| | 242 | end |
| | 243 | |
| | 244 | task :default => :testall |
| 223 | 245 | |
| 224 | 246 | desc "Run all tests" |
| … |
… |
|
| 247 | 269 | end |
| 248 | 270 | |
| 249 | | task :gcov2html => :do_gcov do |
| | 271 | desc "Generate .rake/gcov_results.html" |
| | 272 | task :gcov2html => [:do_gcov, '.rake/gcov_history.jpg'] do |
| 250 | 273 | puts "Generating .rake/gcov_results.html..." |
| 251 | 274 | File.open('.rake/gcov_results.html', 'w') do |f| |
| 252 | 275 | f.write(ERB.new(File.read('.rake/gcov_results.erb')).result(binding)) |
| 253 | 276 | end |
| | 277 | end |
| | 278 | |
| | 279 | file '.rake/gcov_history.data' => GCOV_HIST_FILE do |t| |
| | 280 | history = load_gcov_history |
| | 281 | start = history.start_date |
| | 282 | File.open(t.name, 'w') do |f| |
| | 283 | history.data.each do |d| |
| | 284 | f.write "%s %.2f\n" % |
| | 285 | [Time.at((d.day + start) * DAY).strftime("%Y-%m-%d"), d.percent] |
| | 286 | end |
| | 287 | end |
| | 288 | end |
| | 289 | |
| | 290 | file '.rake/gcov_history.jpg' => '.rake/gcov_history.data' do |t| |
| | 291 | sh "gnuplot .rake/gcov_history.plot" |
| 254 | 292 | end |
| 255 | 293 | |
| … |
… |
|
| 282 | 320 | $gcov_results.total_lines = total_lines |
| 283 | 321 | $gcov_results.covered_lines = covered_lines |
| 284 | | $gcov_results.percent = 100.0 * covered_lines /total_lines |
| | 322 | $gcov_results.percent = percent = 100.0 * covered_lines /total_lines |
| | 323 | history = load_gcov_history |
| | 324 | today = Time.now.to_i/DAY - history.start_date |
| | 325 | history.data.pop if history.data.last.day == today |
| | 326 | history.data << OpenStruct.new(:day => today, |
| | 327 | :total => total_lines, |
| | 328 | :covered => covered_lines, |
| | 329 | :percent => percent) |
| | 330 | File.open(GCOV_HIST_FILE, 'w') {|f| f.write(Marshal.dump(history))} |
| 285 | 331 | end |
| 286 | 332 | |
| … |
… |
|
| 472 | 518 | desc "Publish the gcoverage results" |
| 473 | 519 | task :gcov => :gcov2html do |
| 474 | | sh %{scp .rake/gcov_results.html www@davebalmain.com:/var/www/ferret} |
| | 520 | sh "scp .rake/gcov_results.html .rake/gcov_history.jpg " + |
| | 521 | "www@davebalmain.com:/var/www/ferret" |
| 475 | 522 | end |
| 476 | 523 | end |