-
Notifications
You must be signed in to change notification settings - Fork 0
Testing
IronRuby tests comprise of unit tests written in C# (project Languages\Ruby\IronRuby.Tests
and tests written in Ruby under Languages\IronRuby\Tests
. The latter include RubySpec tests (Languages\IronRuby\Tests\mspec
) and tests copied from test suites of various Ruby libraries, gems and frameworks (Languages\IronRuby\Tests\Libraries
), like Rails, Rake, Yaml, etc.
To run all tests simply execute irtests
on a dev environment command line. This command runs a script Languages\Ruby\Tests\Scripts\irtests.rb
that sets up and executes all the available tests. Use irtests -p
on a multi-core machine, it launches multiple processes running the test suites in parallel.
RubySpec is a project to write a complete, executable specification for the Ruby programming language. The IronRuby GIT repo includes a copy of the RubySpec tests, including the MSpec test framework, under Languages\IronRuby\Tests\mspec
. This makes it easy to modify existing tests or write new tests, and fix the bugs in the IronRuby sources, all in a single commit to the IronRuby repo.
The repo also includes tags in Languages\IronRuby\Tests\mspec\ironruby-tags-19
to disable tests which are known to fail with IronRuby, which should allow clean runs against IronRuby. A developer who is adding features to IronRuby is responsible for updating the tags to establish a new baseline.
The IronRuby team periodically pushes any RubySpec changes done in the IronRuby repo back to the main RubySpec repo, ensuring that the changes are shared across the larger Ruby community.
To validate an IronRuby build, you should run irtests
which builds all the components and runs all the tests, including RubySpec, RubyGems, and RoR 3 test suites. The information below is more information about just the RubySpec tests as it is the major component of all the tests that are run by @irtests.
Here are some example commands for common RubySpec commands:
-
mspec ci core\array\append
– Run all the specs for Array#append that are expected to pass -
mspec ci -S "correctly resizes the Array" core\array\append
– Run just one of the examples (aka. test case) for Array#append -
mspec -tr core\array\append
– Run all the specs for Array#append using MRI (ruby.exe needs to be on the path)
MSpec includes a number of runners for different ways of running the tests. See http://rubyspec.org/wiki/mspec/Runners for the details, including the command line options. Here is the quick overview:
-
mspec
– this callsmspec-run
which runs all specs without looking at any tags -
mspec ci
– this callsmspec-ci
which runs all specs that aren’t tagged fails, critical, unstable, incomplete, or unsupported -
mspec tag
– this callsmspec-tag
which runs all specs without looking at any tags. It also creates tags for failing specs
The .mspecrc
that gets copied into your home directory by dev.bat
loads Merlin\External.LCA_RESTRICTED\Languages\IronRuby\mspec\default.mspec
which defines some targets to make running sets of the specs easier.
-
mspec :cli
– Command line specs -
mspec :core
– Core specs -
mspec :lib
– Library specs -
mspec :lang
– Language specs -
mspec :interop
– .NET interop specs
When you run dev.bat, it puts a .mspecrc
file in your home directory. It also puts the mspec runners into your path.
All path’s you call mspec with are attempted relative to the current location, and relative to a prefix, which for IronRuby is Languages\IronRuby\Tests\mspec\rubyspec
. Mspec also attempts to append _spec.rb
to the string you pass in. This is why you can run the Array#append specs with mspec ci core\array\append
. The long form would be mspec ci core/array/append_spec.rb