Changeset 4510

Show
Ignore:
Timestamp:
01/13/08 00:27:17 (5 years ago)
Author:
walf443
Message:

dotfiles/cutagem/templates/walf443-default:

  • change test using Spec::Rake::SpecTask?.
  • add spec/spec.opts for autotest
  • add rcov task
  • add heckle task
Location:
dotfiles/cutagem/templates/walf443-default
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • dotfiles/cutagem/templates/walf443-default/Rakefile

    r4323 r4510  
    2121 
    2222EXTRA_RDOC_FILES = [] 
     23HECKLE_ROOT_MODULES = ["<%= gemclass %>"] 
    2324 
    2425SPEC = Gem::Specification.new do |s| 
  • dotfiles/cutagem/templates/walf443-default/tasks/basic_tasks.rake

    r4323 r4510  
    88end 
    99 
    10 task :default => [:test] 
     10task :default => [:spec] 
     11task :test    => [:spec] 
    1112task :package => [:clean] 
    1213 
    13 Rake::TestTask.new("test") do |t| 
    14         t.libs   << "spec" 
    15         t.pattern = "spec/**/*_spec.rb" 
    16         t.verbose = true 
     14require 'spec/rake/spectask' 
     15Spec::Rake::SpecTask.new(:spec) do |t| 
     16  t.spec_files = FileList['spec/**/*_spec.rb'] 
     17  t.spec_opts = ['--options', 'spec/spec.opts'] 
     18  t.warning = true 
     19  t.rcov = true 
     20  t.rcov_dir = 'doc/output/coverage' 
     21  t.rcov_opts = ['--exclude', 'spec,\.autotest'] 
     22end 
     23 
     24desc "Heckle each module and class in turn" 
     25task :heckle => :spec do 
     26  root_modules = HECKLE_ROOT_MODULES 
     27  spec_files = FileList['spec/**/*_spec.rb'] 
     28   
     29  current_module, current_method = nil, nil 
     30  heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] } 
     31  unhandled_mutations = 0 
     32   
     33  root_modules.each do |root_module| 
     34    IO.popen("heckle #{root_module} -t #{spec_files}") do |pipe| 
     35      while line = pipe.gets 
     36        line = line.chomp 
     37         
     38        if line =~ /^\*\*\*  ((?:\w+(?:::)?)+)#(\w+)/ 
     39          current_module, current_method = $1, $2 
     40        elsif line == "The following mutations didn't cause test failures:" 
     41          heckle_caught_modules[current_module] << current_method 
     42        elsif line == "+++ mutation" 
     43          unhandled_mutations += 1  
     44        end 
     45               
     46        puts line 
     47      end 
     48    end 
     49  end 
     50   
     51  if unhandled_mutations > 0 
     52    error_message_lines = ["*************\n"] 
     53     
     54    error_message_lines <<  
     55      "Heckle found #{unhandled_mutations} " +  
     56      "mutation#{"s" unless unhandled_mutations == 1} " + 
     57      "that didn't cause spec violations\n" 
     58 
     59    heckle_caught_modules.each do |mod, methods| 
     60      error_message_lines << 
     61        "#{mod} contains the following poorly-specified methods:" 
     62      methods.each do |m|  
     63        error_message_lines << " - #{m}" 
     64      end 
     65      error_message_lines << "" 
     66    end 
     67     
     68    error_message_lines << 
     69      "Get your act together and come back " + 
     70      "when your specs are doing their job!" 
     71     
     72    puts "*************" 
     73    raise error_message_lines.join("\n") 
     74  else 
     75    puts "Well done! Your code withstood a heckling." 
     76  end 
     77end 
     78 
     79require 'spec/rake/verify_rcov' 
     80RCov::VerifyTask.new(:rcov => :spec) do |t| 
     81  t.index_html = "doc/output/coverage/index.html" 
     82  t.threshold = 100 
    1783end 
    1884