[Ironruby-core] Debugging rubyspecs

Pete Bacon Darwin bacondarwin at googlemail.com
Sun Feb 22 04:28:59 EST 2009


OK so I worked it out.

 

Mspec-run does indeed run only a single process but it still requires
mspec/lib/mspec/helpers/ruby_exe.rb.  This file tries to set a constant
called RUBY_EXE but it is not able to do so:  It tries to guess it from
various environment, constant and config settings.  Since ir does not set
RUBY_NAME you have to do something like set the environment variable
RUBY_EXE or have a ~/.mspecrc file that specifies the :target => ... and so
on.

 

Pete

 

From: ironruby-core-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jim Deville
Sent: Thursday,19 February 19, 2009 18:09
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Debugging rubyspecs

 

All the versions that IronRuby has used, have the outer layer CRuby process
kick off a target implementation process. If you call mspec -fs core -t
"ir.exe", it becomes a call to ir.exe mspec-run -fs core. For many of the
specs, you can skip the outer layer, and run mspec-run (or mspec-ci, or
mspec-tag) directly. For debugging, this is what Shri is talking about.

 

As a side note, I advise not doing it this way in general, since there are
environment variables set via the outer layer runner, which will affect the
operation of Mspec. Until now, it has only been MSPEC_RUNNER=1, which tells
Mspec that the specs are being run by Mspec, not Rspec. However, Mspec also
sets RUBY_EXE and RUBY_OPTIONS, to the values of the -t and -T flags.

 

Now that ir -e works (I will be pushing the new revision today), these
variables will affect the operation of the specs. Many of the specs that
test top level code, depend on testing a fresh process, or test the command
line options (I am adding these right now) use the ruby_exe helper. This
helper starts a new process of the currently running implementation to run
the specified command or file. Using the outer layer with -t and -T ensures
that these specs are run on the proper implementation and options. I know
that the implementation attempts to be inferred via other means (RUBY_NAME,
RUBY_PLATFORM), but the options are not as easily taken care of. 

 

The wiki (http://wiki.github.com/ironruby/ironruby/rubyspec) tells how to
get things set up, and if you set things up correctly (using ~/.mspecrc and
setting /path/to/mspec/bin in your PATH) you can run a spec file as easily
as mspec ci core/array/pack (to run core/array/pack_spec.rb). You have to
make sure set :target, "/path/to/ir.exe" and set :prefix, "path/to/rubyspec"
are set in ~/.mspecrc, from there it should just work.

 

Let me know if you have more questions on any of this.

 

JD

 

From: ironruby-core-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Pete Bacon Darwin
Sent: Thursday, February 19, 2009 6:21 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Debugging rubyspecs

 

Hi Shri and Jimmy,

 

Thanks for the suggestions.  What version of mspec are you running?  I am
running the head version directly from rubyspecs github: "d482804 Added
should have_constant matcher."

 

In my version, the initial ruby process kicks off a new ruby process
(potentially a completely different implementation, like JRuby or Rubinius)
for each test run.  So there is no point in debugging the initial process.

 

Shri, on my machine your instructions below result in "unknown: Unable to
find a suitable ruby executable. (Exception)", which I guess is mspec
telling me it couldn't load ir.exe or equivalent as a sub-process for
executing the spec.

 

Jimmy, how do you attach to the mspec process in the first place?  The same
problem as above is true for just debugging mspec run ...

 

Pete

 

From: ironruby-core-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Shri Borde
Sent: Wednesday,18 February 18, 2009 17:59
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Debugging rubyspecs

 

Here is what I added to http://wiki.github.com/ironruby/ironruby. This works
pretty well for me. If the paths are incorrect, feel free to update the
wiki.

 

Debugging with Visual Studio

In the Debug tab of the Project properties for Ruby.Console.csproj, set the
fields as follows: 

*	Start Action: For Ruby.Console.csproj, "Start project" should be
enabled. 

For any other project, "Start external program:" should be enabled and set
to "c:\vsl\Merlin\Main\Bin\Debug\ir.exe"

*	Start Options: "Command line arguments" should be set to the
following for running the "supports /i for ignoring case" example of
string\gsub_spec.rb: 

-v -X:Interpret
c:/vsl/Merlin/External/Languages/IronRuby/mspec/mspec/bin/mspec-run -e
"supports /i for ignoring case" -fs -V -B
c:/vsl/Merlin/External/Languages/IronRuby/mspec/default.mspec
c:/vsl/Merlin/External/Languages/IronRuby/mspec/rubyspec/1.8/core/string/gsu
b_spec.rb 

Hitting F5 should now run the single RubySpec example under VS

 

 

Thanks,

Shri

 

From: ironruby-core-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jimmy Schementi
Sent: Wednesday, February 18, 2009 8:52 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Debugging rubyspecs

 

You can pass the spec file to mspec itself like:

 

mspec run core/io/popen_close

 

Then I make a call to "debugger" http://gist.github.com/61605, which breaks
on a call to System::Diagnostics::Debugger when a debugger is attached to
the app. Unfortunately this breaks in a Ruby method, so you have to jump up
a couple CLR frames to get to the line directly after the "debugger" call,
and I'm not sure of a way how to do that automatically. Anyway, this works
great.

 

~js

 

From: ironruby-core-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Pete Bacon Darwin
Sent: Wednesday, February 18, 2009 8:11 AM
To: 'Pete Bacon Darwin'; ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Debugging rubyspecs

 

The easiest way it appears is to stick a pause in the rubyspec of interest
and attach to the process while it is waiting.  It does totally kill the
computer performance while you are debugging (like minutes to step through
each line!)

Pete

 

From: Pete Bacon Darwin [mailto:bacondarwin at googlemail.com] 
Sent: Wednesday,18 February 18, 2009 15:19
To: 'ironruby-core at rubyforge.org'
Subject: Debugging rubyspecs

 

Anybody know how to run rubyspecs under the Visual Studio debugger?  If I
just set the rubyspec file as the command line argument in the debug
properties in VS then it just asks me to install mspec as a gem.

Pete

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090222/1f3db773/attachment-0001.html>


More information about the Ironruby-core mailing list