The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Testing for ruby 1.8 and 1.9 using multiruby

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ryan Davis

Posts: 651
Nickname: zenspider
Registered: Oct, 2004

Ryan Davis is a ruby nerd.
Testing for ruby 1.8 and 1.9 using multiruby Posted: Dec 27, 2007 4:23 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Ryan Davis.
Original Post: Testing for ruby 1.8 and 1.9 using multiruby
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby

Advertisement

Now that 1.9 is out, it is time to talk about multi-version testing using multiruby. multiruby is a lesser known tool in the zentest family. It automatically builds and privately installs multiple versions of ruby and multiplexes commands to all of them, allowing you to run your tests across multiple versions of ruby all at once.

If you read this blog, you probably already have zentest and multiruby is already available to you. If not, sudo gem install zentest and you're good to go. You can try it out now (tho I recommend updating zentest to the latest version for all the candy) and you should see something like this:

% multiruby -e 'p 1+1'
creating /Users/ryan/.multiruby
creating build
creating install
creating versions
  Downloading initial ruby tarballs to ~/.multiruby/versions:
    ruby-1.8.6-p111.tar.gz via HTTP... this might take a while.
    ruby-1.9.0-0.tar.gz via HTTP... this might take a while.
  ...done
  Put other ruby tarballs in ~/.multiruby/versions to use them.
creating /Users/ryan/.multiruby/install/1.8.6-p111
Running command: tar zxf ../versions/ruby-1.8.6-p111.tar.gz
building and installing 1.8.6-p111
Running command: ./configure --prefix /Users/ryan/.multiruby/install/1.8.6-p111 &> log.configure
Running command: nice make -j4 &> log.build
Running command: make install &> log.install
creating /Users/ryan/.multiruby/install/1.9.0-0
Running command: tar zxf ../versions/ruby-1.9.0-0.tar.gz
building and installing 1.9.0-0
Running command: ./configure --prefix /Users/ryan/.multiruby/install/1.9.0-0 &> log.configure
Running command: nice make -j4 &> log.build
Running command: make install &> log.install

VERSION = 1.8.6-p111

2

RESULT = 0

VERSION = 1.9.0-0

2

RESULT = 0

TOTAL RESULT = 0 failures out of 2

Passed: 1.8.6-p111, 1.9.0-0
Failed:

Of course, it only builds when it detects new versions in the versions directory. The next time you run it should be much faster and cleaner:

% multiruby -e 'p 1+1'

VERSION = 1.8.6-p111

2

RESULT = 0

VERSION = 1.9.0-0

2

RESULT = 0

TOTAL RESULT = 0 failures out of 2

Passed: 1.8.6-p111, 1.9.0-0
Failed:

What this really boils down to is this: you now have a command that you can use in place of ruby to test on multiple versions of ruby. Where before you'd type rake and get:

% rake
(in /Users/ryan/Work/p4/zss/src/ZenTest/dev)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -w -Ilib:ext:bin:test -e 'require "test/test_autotest.rb"; require "test/test_help.rb"; require "test/test_rails_autotest.rb"; require "test/test_rails_controller_test_case.rb"; require "test/test_rails_helper_test_case.rb"; require "test/test_rails_view_test_case.rb"; require "test/test_unit_diff.rb"; require "test/test_zentest.rb"; require "test/test_zentest_assertions.rb"; require "test/test_zentest_mapping.rb"; require "test/unit"'
Loaded suite -e
Started
......................................................................................................................................
Finished in 0.1947 seconds.

134 tests, 425 assertions, 0 failures, 0 errors

Now you can grab that ruby command and run it with multiruby instead:

% multiruby -w -Ilib:ext:bin:test -e 'require "test/test_autotest.rb"; require "test/test_help.rb"; require "test/test_rails_autotest.rb"; require "test/test_rails_controller_test_case.rb"; require "test/test_rails_helper_test_case.rb"; require "test/test_rails_view_test_case.rb"; require "test/test_unit_diff.rb"; require "test/test_zentest.rb"; require "test/test_zentest_assertions.rb"; require "test/test_zentest_mapping.rb"; require "test/unit"' 

VERSION = 1.8.6-p111

Loaded suite -e
Started
.........................................................................................................
Finished in 0.148562 seconds.

105 tests, 338 assertions, 0 failures, 0 errors

RESULT = 0

VERSION = 1.9.0-0

Loaded suite -e
Started
..................................................................................................................................
Finished in 0.147284 seconds.

130 tests, 407 assertions, 0 failures, 0 errors

RESULT = 0

TOTAL RESULT = 0 failures out of 2

Passed: 1.8.6-p111, 1.9.0-0
Failed:

But wait, there's MORE! As an added bonus, if you're using hoe on your project, you already have a rake multi task that does the running for you, no icky copy and paste!

That is all there is to it (besides fixing 1.9 compatibilities, of course), so get out there and test your code!

Read: Testing for ruby 1.8 and 1.9 using multiruby

Topic: Graphing Spam Previous Topic   Next Topic Topic: adios

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use