Changeset 53eafd97a7caf432dce29b625005d7e028ae5b62

Show
Ignore:
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:
2 added
1 modified

Legend:

Unmodified
Added
Removed
  • c/Rakefile

    r340bd7 r53eafd  
    5555  sh script 
    5656end 
     57 
     58### 
     59# Useful Constants 
     60### 
     61 
     62DAY = 24 * 60 * 60 # seconds in day 
    5763 
    5864### 
     
    179185  if copts != old_copts 
    180186    File.open(copts_file, 'w') {|f| f.write(Marshal.dump(copts))} 
    181     Rake::Task[:clean].invoke 
     187    Rake::Task[:scrub].invoke 
    182188  end 
    183189end 
     
    197203                  '*.gcov', 
    198204                  'y.tab.c']) 
    199  
    200205CLOBBER.include([ '*.a', 
    201206                  '**/*.o', 
     
    207212                  GCOV_DIR]) 
    208213 
    209 task :default => :testall 
    210  
     214SCRUB = FileList[CLEAN, '**/*.o'] 
     215desc "clean for rebuild" 
     216task :scrub do 
     217  SCRUB.each {|fn| rm_r fn rescue nil} 
     218end 
     219 
     220### 
     221# Test Helpers 
     222### 
    211223def run_tests 
    212224  check_coptions 
     
    221233  FileList['.rake/HAVE_*'].each {|fn| CFLAGS << File.read(fn)} 
    222234end 
     235 
     236### 
     237# gcov Helpers 
     238### 
     239GCOV_HIST_FILE = ".rake/gcov.history" 
     240def load_gcov_history 
     241  Marshal.load(File.read(GCOV_HIST_FILE)) 
     242end 
     243 
     244task :default => :testall 
    223245 
    224246desc "Run all tests" 
     
    247269end 
    248270 
    249 task :gcov2html => :do_gcov do 
     271desc "Generate .rake/gcov_results.html" 
     272task :gcov2html => [:do_gcov, '.rake/gcov_history.jpg'] do 
    250273  puts "Generating .rake/gcov_results.html..." 
    251274  File.open('.rake/gcov_results.html', 'w') do |f| 
    252275    f.write(ERB.new(File.read('.rake/gcov_results.erb')).result(binding)) 
    253276  end 
     277end 
     278 
     279file '.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 
     288end 
     289 
     290file '.rake/gcov_history.jpg' => '.rake/gcov_history.data' do |t| 
     291  sh "gnuplot .rake/gcov_history.plot" 
    254292end 
    255293 
     
    282320  $gcov_results.total_lines = total_lines 
    283321  $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))} 
    285331end 
    286332 
     
    472518  desc "Publish the gcoverage results" 
    473519  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" 
    475522  end 
    476523end