sj26 / rspec_junit_formatter

RSpec results that your CI can read

Home Page:http://rubygems.org/gems/rspec_junit_formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RSpec Issue with RVM on Linux and OSX

wolfeidau opened this issue · comments

Having some issues using this gem with RVM.

As far as I can tell there is an issue with the file being located within the core rspec namespace. Intially I thought it was an RVM thing however I have run the test in a bare env with only the environment variables required for ruby and gem to work, this had the same issue.

Based on the messages we exchanged yesterday I understand why it is located in that namespace, however having hacked the project to move it to a empty namespace, similar to Fuubar formatter, I have made the gem work.

As I am quite a new to ruby I am not entirely sure my rather large changes are necessary. That said I have a feeling there were some other minor issues I flushed out while doing so. These are mainly related to requires statements and were uncovered when i added a spec to try out the changes.

I have checked in my updates to https://github.com/wolfeidau/rspec_junit_formatter if you could have a look at what I have done that would be great.

    $ rspec spec 
    /home/markw/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- j_unit_formatter (LoadError)
        from /home/markw/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:522:in `rescue in custom_formatter'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:519:in `custom_formatter'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:301:in `add_formatter'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/configuration_options.rb:22:in `block in configure'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/configuration_options.rb:22:in `each'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/configuration_options.rb:22:in `configure'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:17:in `run'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
        from /home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun'

OK I did an strace while running rspec with the 0.1.1 version and rspec seems to be searching for the following.

    stat("/home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec_junit_formatter-0.1.1", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
    stat("/home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec_junit_formatter-0.1.1/lib/j_unit_formatter", 0x7fff41d4afa0) = -1 ENOENT (No such file or directory)
    stat("/home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec_junit_formatter-0.1.1/lib/j_unit_formatter.rb", 0x7fff41d4afa0) = -1 ENOENT (No such file or directory)
    stat("/home/markw/.rvm/gems/ruby-1.9.3-p0@rails31/gems/rspec_junit_formatter-0.1.1/lib/j_unit_formatter.so", 0x7fff41d4afa0) = -1 ENOENT (No such file or directory)

As you can see it cant locate the file so all bad.. The file that is present in this folder is named rspec_junit_formatter.rb

Rather than the configuration below, from the ReadMe

    --format JUnitFormatter
    --out rspec.xml

If i use the following it works!

    --format RspecJunitFormatter
    --out rspec.xml

We use rspec_junit_formatter on linux with rvm in our jenkins builds. I suspect you're not loading the gem before using the formatter.

Gems need to be required to be added to the load path by rubygems. In this case, you must require "rspec_junit_formatter" before using j_unit_formatter.

Try:

rspec -r rspec_junit_formatter -f j_unit_formatter spec

I'll update the README so this is a little more clear, I notice I've used --format RspecJunitFormatter and --format JUnitFormatter in there which is probably not helping!

Yeah being new to Ruby I think I took a very long path to the same destination, although I did learn a lot in the process.

I am planning to use it with Atlassian Bamboo CI server for pretty much the same reason.

/agree the issue I was having was mostly triggered by README

Thanks a lot for replying so promptly and sorry for hassling you so much :P

Not a problem! Thanks, the README has been updated in 1f1792c. :-)