Jeremy Durham

Ruby, Rails, and everything in between.

  • BlogThoughts
  • AboutAbout the Author
  • ContactGet in touch

July 18, 2010 19:00
Posted by Jeremy Durham

CI rerun

A new design and now a new post. I’m on fire!

I’ve been spending a little more time lately optimizing our build times, and ran across a useful snippet I’d written a few months ago.

We have a few projects with over 4000 Selenium features (we love that Javascript!), and every once in a while we run into a few false positives. Features will run slow on the build machine and cause the build to fail, even though it shouldn’t.

Cucumber supports a “rerun” format, where it will output a rerun.txt file of all the files that failed. You can push that rerun.txt back through Cucumber to just rerun those features.

Here’s the code from ci.rake:

namespace :ci do
  task :all do
    rerun = "#{Rails.root}/rerun.txt"
    RAILS_ENV = 'test'
    Rake::Task['log:clear'].invoke
    Rake::Task['setup:app'].invoke
    Rake::Task['spec'].invoke
    FileUtils.rm_f rerun if File.exist?(rerun)
    begin
      Rake::Task['ci:features'].invoke
    rescue Exception => e
      if File.exist?(rerun)
        rerun_features = IO.read(rerun)
        Cucumber::Rake::Task.new(:rerun_selenium_features) do |t|
          t.cucumber_opts = "--format progress -q #{IO.read("#{Rails.root}/rerun.txt")}"
        end
        Rake::Task['rerun_selenium_features'].invoke unless rerun_features.to_s.strip.empty?
      end
    end
  end
  Cucumber::Rake::Task.new(:features) do |t|
    t.cucumber_opts = "-q --format rerun --out #{Rails.root}/rerun.txt"
  end
end

It’s important not to blindly use this task; if you continue to run into the same feature failing over and over again, it could be another issue. We’ve seen instances where stories will set some persistent data in the browser’s local storage, and later stories will fail unless run in isolation. Make sure you’re looking at your build output regularly!

No Comments

Posted Under Programming

  • Posts
  • Twitter
  • Flickr
 

There is no Holy ...

Technology

 

Google and Apple:...

Technology

 

Setting up Git an...

Technology

@mariusrugan awesome, glad I was able to be of some help

follow me on
twitter

125942640_a3dcc3f951_s125942637_c4524c7c88_s125942628_a682f8a639_s122144184_5f2dd86929_s122144182_1b01ded312_s122144181_893a82f1d3_s122144179_70465b00ff_s122102402_21e6174af6_s122102401_f6d9ebff55_s

Categories

  • Technology
  • Programming
  • Family
  • Travel

This site is using the Handgloves WordPress Theme
Designed & Developed by George Wiscombe

Subscribe via RSS