Forum: RSpec RSpec and RCov with JRuby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Acac620db34f728646f7872517b3a5af?d=identicon&s=25 Tobias Torkler (Guest)
on 2008-03-17 13:30
(Received via mailing list)
Hi,

I am using JRuby (trunk) and wrote a bunch of specifications for my
code. Everything works fine so far.
Now I am trying to integrate RCov in my test run. I have installed
RCov without the C extensions. I tried it with a simple script and it
worked (pretty slow, but it doesn´t matter).
But when I add the rcov options to my Rake task, RCov is not invoke
properly!

Rakefile:
Spec::Rake::SpecTask.new('specs') do |t|
   t.spec_files = FileList['spec/**/*.rb']
   t.rcov = true
   t.rcov_opts = ['--exclude', 'spec']
   t.verbose = true
end

Output:
...
Finished in 11.376 seconds

187 examples, 0 failures, 10 pending
Loaded suite /Users/tobias/bin/JRuby.framework/Current/bin/rcov
Started

Finished in 0.0080 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

Why is rcov started at the end of the test run?
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 aslak hellesoy (Guest)
on 2008-03-17 15:45
(Received via mailing list)
On Mon, Mar 17, 2008 at 1:27 PM, Tobias Torkler <tobias.torkler@meco.de>
wrote:
>  Rakefile:
>
>  187 examples, 0 failures, 10 pending
>  Loaded suite /Users/tobias/bin/JRuby.framework/Current/bin/rcov
>  Started
>
>  Finished in 0.0080 seconds.
>
>  0 tests, 0 assertions, 0 failures, 0 errors
>

This is Test::Unit output

>  Why is rcov started at the end of the test run?

Did you mean: Why is Test::Unit started at the end of the RSpec run?

I'm not sure exactly what you're asking.

Aslak
Acac620db34f728646f7872517b3a5af?d=identicon&s=25 Tobias Torkler (Guest)
on 2008-03-17 15:57
(Received via mailing list)
This is not Test::Unit output!
As you can see I created a Rake task to run my specs and tried to
integrate rcov as described on
http://rspec.info/documentation/tools/rcov.html
RSpec works as expected (187 examples, 0 failures, 10 pending) but I
am missing the RCov report.


Am 17.03.2008 um 15:43 schrieb aslak hellesoy:
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 aslak hellesoy (Guest)
on 2008-03-17 16:26
(Received via mailing list)
On Mon, Mar 17, 2008 at 3:50 PM, Tobias Torkler <tobias.torkler@meco.de>
wrote:
> This is not Test::Unit output!

The following text - taken from your first email - is Test::Unit
output. It is not RCov or RSpec output.

------------8<------------
Loaded suite /Users/tobias/bin/JRuby.framework/Current/bin/rcov
  Started

  Finished in 0.0080 seconds.

  0 tests, 0 assertions, 0 failures, 0 errors
------------8<------------

>  As you can see I created a Rake task to run my specs and tried to
>  integrate rcov as described on http://rspec.info/documentation/tools/rcov.html
>  RSpec works as expected (187 examples, 0 failures, 10 pending) but I
>  am missing the RCov report.
>

In your first email you asked: Why is rcov started at the end of the
test run?
I got confused about what you mean by "test run" (that usually mean
Test::Unit run - and you do have Test::Unit output).

Are you trying to figure out what order things are happening in, or
are you trying to figure out why you're not getting an RCov report?

Aslak
Acac620db34f728646f7872517b3a5af?d=identicon&s=25 Tobias Torkler (Guest)
on 2008-03-17 16:27
(Received via mailing list)
Ok, so the question is then why I don´t get an RCov report? Sorry for
the "test run". Better call it an RSpec run?


Am 17.03.2008 um 16:10 schrieb aslak hellesoy:
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 aslak hellesoy (Guest)
on 2008-03-17 17:43
(Received via mailing list)
On Mon, Mar 17, 2008 at 4:23 PM, Tobias Torkler <tobias.torkler@meco.de>
wrote:
> Ok, so the question is then why I don´t get an RCov report? Sorry for
>  the "test run". Better call it an RSpec run?
>

RSpec run is much clearer, thanks :-)

I'm looking into the problem, but I'm struggling to install RCov into
JRuby. I get the following error:

$ /usr/local/jruby-1.1RC2/bin/jruby -S gem install rcov
Building native extensions.  This could take a while...
extconf.rb:1: no such file to load -- mkmf (LoadError)
ERROR:  Error installing rcov:
        ERROR: Failed to build gem native extension.

/usr/local/jruby-1.1RC2/bin/jruby extconf.rb install rcov


Gem files will remain installed in
/usr/local/jruby-1.1RC2/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0 for
inspection.
Results logged to
/usr/local/jruby-1.1RC2/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/ext/rcovrt/gem_make.out

How did you install rcov bypassing the building of the C extensions?

Aslak
Acac620db34f728646f7872517b3a5af?d=identicon&s=25 Tobias Torkler (Guest)
on 2008-03-17 17:57
(Received via mailing list)
1. Download http://eigenclass.org/static/rcov/rcov-0.8.1.2.tar.gz and
extract the archive
2. jruby -S setup.rb all --without-ext
3. Change shebang of <jruby-dir>/bin/rcov to #!/usr/bin/env jruby
4. rcov script.rb should work now (warning appears, that no extensions
are installed)


Am 17.03.2008 um 17:37 schrieb aslak hellesoy:
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 aslak hellesoy (Guest)
on 2008-03-17 19:57
(Received via mailing list)
On Mon, Mar 17, 2008 at 5:47 PM, Tobias Torkler <tobias.torkler@meco.de>
wrote:
> 1. Download http://eigenclass.org/static/rcov/rcov-0.8.1.2.tar.gz and
>  extract the archive
>  2. jruby -S setup.rb all --without-ext
>  3. Change shebang of <jruby-dir>/bin/rcov to #!/usr/bin/env jruby
>  4. rcov script.rb should work now (warning appears, that no extensions
>  are installed)
>

Thanks, those installation instructions were useful.

Unfortunately, I'm unable to run RCov 0.8.1.2 on JRuby 1.1.RC2 at all:

$ /usr/local/jruby-1.1RC2/bin/jruby -S rcov --version
Exception in thread "main" java.lang.RuntimeException: MethodBlock
does not have a static scope; this should not be called
        at
org.jruby.runtime.MethodBlock.getStaticScope(MethodBlock.java:128)
        at org.jruby.RubyModule.createProcMethod(RubyModule.java:1079)
...
(lots more)
...
        at org.jruby.Main.main(Main.java:79)

Can you recommend a JRuby version where RCov will actually start up?

Aslak
Acac620db34f728646f7872517b3a5af?d=identicon&s=25 Tobias Torkler (Guest)
on 2008-03-17 20:19
(Received via mailing list)
That´s right, sorry! There was a call and it will be fixed in RC3.
But you can checkout the sources
(http://svn.codehaus.org/jruby/trunk/jruby/
) and build the jruby.jar via ant.
It will work then!

I know it´s complicated, but I need this for my diploma thesis and I
appreciate your help!


Am 17.03.2008 um 19:54 schrieb aslak hellesoy:
Acac620db34f728646f7872517b3a5af?d=identicon&s=25 Tobias Torkler (Guest)
on 2008-03-17 22:09
(Received via mailing list)
Issue is solved!!!
I had a require 'test/unit' in my spec_helper.rb. I removed it and it
works now.


Am 17.03.2008 um 20:08 schrieb Tobias Torkler:
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 aslak hellesoy (Guest)
on 2008-03-17 22:16
(Received via mailing list)
On Mon, Mar 17, 2008 at 10:04 PM, Tobias Torkler
<tobias.torkler@meco.de> wrote:
> Issue is solved!!!
>  I had a require 'test/unit' in my spec_helper.rb. I removed it and it
>  works now.

Good. That makes sense. Two competing exit hooks or something. I bet
your Test::Unit output went away too.

Aslak
This topic is locked and can not be replied to.