Packaging talk:Ruby

From FedoraProject

Revision as of 12:44, 1 February 2011 by Mtasaka (Talk | contribs)

Jump to: navigation, search

The following metadata was found in MoinMoin that could not be converted to a useful value in MediaWiki:

  •  : These two files are symlinks into %gemdir created in %install
  • acl: Known:read,write All:read

The short tutorial how to put an rpm file created with gem2rpm in compliance is here: http://lukas.zapletalovi.com/2011/01/how-to-prepare-gemfile-package-for.html

Contents

Testsuite execution

The most, if not all gems contains their test suite, which is commonly executed during build. This might be in most cases achieved by running rake task such as:

%check
rake spec

However this has some cavities. The problem is mainly that Rakefile usually contains not just the "spec" or "test" task for test suite execution, but also packaging tasks etc. These tasks usually depends on other gems, such as "Hoe". This brings in unnecessary dependencies and polution. Therefore, please prefer to execute the test suite as follows:

Test::Unit

RUBYOPT="I%{buildroot}%{geminstdir}/lib Itest" testrb test/test_*

MiniTest

RUBYOPT="I%{buildroot}%{geminstdir}/lib Itest" ruby -e "Dir.glob('test/**/test_*').each {|t| require t}"

RSpec

RUBYOPT="I%{buildroot}%{geminstdir}/lib Ispec" spec spec/


Additional notes

If the test suite has more dependencies, RUBYOPT can additionally enforce usage of RubyGems. This apply for all test frameworks mentioned above.

RUBYOPT="rubygems I%{buildroot}%{geminstdir}/lib Ispec" spec spec/

Why? Just adding "BR: rubygem(hoe)" and executing $ rake test" is much simpler and easier to maintain. Also using $rake check is useful because it can check if the Rakefile itself is valid or not. Please avoid such comprecated and unneeded craft as much as possible which makes spec file less readable and less maintainable. Note that BuildRequires != Requires. Adding BuildRequires does not add "runtime" dependency. If running $ rake check requires additional packages, please try to add them to Fedora project when possible. It is more useful than resorting to unusual way. - 2011-02-01 UTC 12:45 Mamoru