[DRE-commits] [gem2deb] 02/03: Centralize references to supported Ruby versions

Antonio Terceiro terceiro at alioth.debian.org
Thu Aug 8 20:45:13 UTC 2013


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to branch master
in repository gem2deb.

commit c1b726344864bf21713915691a7978495043a6af
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Thu Aug 8 22:38:54 2013 +0200

    Centralize references to supported Ruby versions
    
    Now for supporting new Ruby versions, the only place that needs to be
    changed -- other than documentation -- is lib/gem2deb.rb
---
 bin/dh_ruby                                    |    3 ++-
 bin/dh_ruby_fixdepends                         |    2 +-
 debian/rules                                   |    3 ++-
 lib/gem2deb.rb                                 |    5 +++++
 lib/gem2deb/dh_make_ruby/template/debian/rules |    2 +-
 test/sample/multibinary/debian/rules           |    2 +-
 test/sample/name_clash_multiple/debian/rules   |    2 +-
 test/test_helper.rb                            |   15 ++++++++++++---
 test/unit/dh_ruby_test.rb                      |   14 ++++++--------
 test/unit/installer_test.rb                    |   12 ++++++------
 test/unit/setup_rb_installer_test.rb           |    4 +---
 11 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/bin/dh_ruby b/bin/dh_ruby
index 73892c5..60dd65c 100755
--- a/bin/dh_ruby
+++ b/bin/dh_ruby
@@ -212,7 +212,8 @@ first !
 
 This is a space-separated list of tests that dh_ruby will ignore during package
 build. The available test names are "require-rubygems" plus the names of all
-supported Ruby versions. At the time of writing, only "ruby1.9.1" is supported.
+supported Ruby versions. At the time of writing, only "ruby1.9.1" and ruby2.0
+are supported.
 
 If set to "all", all tests will be ignored during the package build.
 
diff --git a/bin/dh_ruby_fixdepends b/bin/dh_ruby_fixdepends
index b0a3494..2ce8c30 100755
--- a/bin/dh_ruby_fixdepends
+++ b/bin/dh_ruby_fixdepends
@@ -29,7 +29,7 @@ include Gem2Deb
       std_deps = []
       ruby_deps = []
       deps.each do |dep|
-        if ['libruby1.9.1'].include?(dep.split(' ')[0])
+        if SUPPORTED_RUBY_SHARED_LIBRARIES.include?(dep.split(' ')[0])
           ruby_deps << dep
         else
           std_deps << dep
diff --git a/debian/rules b/debian/rules
index cf75b2d..094b8f0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,7 +6,8 @@
 override_dh_auto_build:
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
 	# NO_PKG_MANGLE=1 is only useful on Ubuntu buildds, to disable pkgbinarymangler
-	NO_PKG_MANGLE=1 ruby1.9.1	-S rake test
+	NO_PKG_MANGLE=1 ruby1.9.1 -S rake test
+	NO_PKG_MANGLE=1 ruby2.0   -S rake test
 endif
 	mkdir -p man
 	for i in bin/*; do pod2man -c "" -r "" $$i > man/$$(basename $$i).1; done
diff --git a/lib/gem2deb.rb b/lib/gem2deb.rb
index f7f7a22..f675144 100644
--- a/lib/gem2deb.rb
+++ b/lib/gem2deb.rb
@@ -34,6 +34,11 @@ module Gem2Deb
     'ruby2.0'   => '2.0',
   }
 
+  SUPPORTED_RUBY_SHARED_LIBRARIES = [
+    'libruby1.9.1',
+    'libruby2.0',
+  ]
+
   RUBY_SHEBANG_CALL = '/usr/bin/env ruby'
 
   BIN_DIR = '/usr/bin'
diff --git a/lib/gem2deb/dh_make_ruby/template/debian/rules b/lib/gem2deb/dh_make_ruby/template/debian/rules
index ded0259..82ddc0c 100644
--- a/lib/gem2deb/dh_make_ruby/template/debian/rules
+++ b/lib/gem2deb/dh_make_ruby/template/debian/rules
@@ -6,7 +6,7 @@
 #
 # Uncomment to ignore some test failures (but the tests will run anyway).
 # Valid values:
-#export DH_RUBY_IGNORE_TESTS=ruby1.9.1 require-rubygems
+#export DH_RUBY_IGNORE_TESTS=ruby1.9.1 ruby2.0 require-rubygems
 #
 # If you need to specify the .gemspec (eg there is more than one)
 #export DH_RUBY_GEMSPEC=gem.gemspec
diff --git a/test/sample/multibinary/debian/rules b/test/sample/multibinary/debian/rules
index ded0259..82ddc0c 100755
--- a/test/sample/multibinary/debian/rules
+++ b/test/sample/multibinary/debian/rules
@@ -6,7 +6,7 @@
 #
 # Uncomment to ignore some test failures (but the tests will run anyway).
 # Valid values:
-#export DH_RUBY_IGNORE_TESTS=ruby1.9.1 require-rubygems
+#export DH_RUBY_IGNORE_TESTS=ruby1.9.1 ruby2.0 require-rubygems
 #
 # If you need to specify the .gemspec (eg there is more than one)
 #export DH_RUBY_GEMSPEC=gem.gemspec
diff --git a/test/sample/name_clash_multiple/debian/rules b/test/sample/name_clash_multiple/debian/rules
index ded0259..82ddc0c 100755
--- a/test/sample/name_clash_multiple/debian/rules
+++ b/test/sample/name_clash_multiple/debian/rules
@@ -6,7 +6,7 @@
 #
 # Uncomment to ignore some test failures (but the tests will run anyway).
 # Valid values:
-#export DH_RUBY_IGNORE_TESTS=ruby1.9.1 require-rubygems
+#export DH_RUBY_IGNORE_TESTS=ruby1.9.1 ruby2.0 require-rubygems
 #
 # If you need to specify the .gemspec (eg there is more than one)
 #export DH_RUBY_GEMSPEC=gem.gemspec
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 135eff1..42ac62f 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -5,12 +5,21 @@ require 'fileutils'
 require 'tmpdir'
 require 'tempfile'
 
+require 'gem2deb'
+
 Gem2DebTestCase = Test::Unit::TestCase
 class Gem2DebTestCase
 
-  VENDOR_ARCH_DIRS = {
-    'ruby1.9.1' => `ruby1.9.1 -rrbconfig -e "puts RbConfig::CONFIG['vendorarchdir']"`.strip,
-  }
+  SUPPORTED_VERSION_NUMBERS = Gem2Deb::RUBY_CONFIG_VERSION.values.sort
+
+  OLDER_RUBY_VERSION = Gem2Deb::SUPPORTED_RUBY_VERSIONS.keys.select { |m| m =~ /^ruby/ }.sort.first
+  OLDER_RUBY_VERSION_BINARY = Gem2Deb::SUPPORTED_RUBY_VERSIONS[OLDER_RUBY_VERSION]
+
+  VENDOR_ARCH_DIRS = {}
+  Gem2Deb::SUPPORTED_RUBY_VERSIONS.keys.each do |version|
+    VENDOR_ARCH_DIRS[version] =
+      `#{Gem2Deb::SUPPORTED_RUBY_VERSIONS[version]} -rrbconfig -e "puts RbConfig::CONFIG['vendorarchdir']"`.strip
+  end
 
   require 'test_helper/samples'
   include Gem2DebTestCase::Samples
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index 6645ecd..2c45c3a 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -31,9 +31,7 @@ class DhRubyTest < Gem2DebTestCase
   end
 
   context 'installing native extension' do
-    [
-      '1.9.1',
-    ].each do |version_number|
+    SUPPORTED_VERSION_NUMBERS.each do |version_number|
       vendorarchdir = VENDOR_ARCH_DIRS['ruby' + version_number]
       target_so = "#{vendorarchdir}/simpleextension.so"
       should "install native extension for Ruby #{version_number}" do
@@ -47,9 +45,7 @@ class DhRubyTest < Gem2DebTestCase
   end
 
   context 'installing native extension with extconf.rb in the sources root' do
-    [
-      '1.9.1',
-    ].each do |version_number|
+    SUPPORTED_VERSION_NUMBERS.each do |version_number|
       vendorarchdir = VENDOR_ARCH_DIRS['ruby' + version_number]
       target_so = "#{vendorarchdir}/simpleextension_in_root.so"
       should "install native extension for Ruby #{version_number}" do
@@ -98,8 +94,10 @@ class DhRubyTest < Gem2DebTestCase
   end
 
   context 'installing gemspec' do
-    should 'install gemspec for simplegem' do
-      assert_installed SIMPLE_GEM_DIRNAME, 'ruby-simplegem', '/usr/share/rubygems-integration/1.9.1/specifications/simplegem-0.0.1.gemspec'
+    SUPPORTED_VERSION_NUMBERS.each do |version|
+      should 'install gemspec for simplegem under Ruby ' + version do
+        assert_installed SIMPLE_GEM_DIRNAME, 'ruby-simplegem', "/usr/share/rubygems-integration/#{version}/specifications/simplegem-0.0.1.gemspec"
+      end
     end
   end
 
diff --git a/test/unit/installer_test.rb b/test/unit/installer_test.rb
index 48466f9..7155fc5 100644
--- a/test/unit/installer_test.rb
+++ b/test/unit/installer_test.rb
@@ -107,10 +107,10 @@ class InstallerTest < Gem2DebTestCase
       @installer.expects(:rewrite_shebangs).with('/usr/bin/env ruby')
       @installer.send(:update_shebangs)
     end
-    should 'rewrite shebang to usr /usr/bin/ruby1.9.1 if only 1.9.1 is supported' do
-      @installer.stubs(:ruby_versions).returns(['ruby1.9.1'])
-      @installer.stubs(:supported_ruby_versions).returns(['ruby1.9.1', 'rubyX.Y'])
-      @installer.expects(:rewrite_shebangs).with('/usr/bin/ruby1.9.1')
+    should "rewrite shebang to usr #{OLDER_RUBY_VERSION_BINARY} if only #{OLDER_RUBY_VERSION} is supported" do
+      @installer.stubs(:ruby_versions).returns([OLDER_RUBY_VERSION])
+      @installer.stubs(:supported_ruby_versions).returns([OLDER_RUBY_VERSION, 'rubyX.Y'])
+      @installer.expects(:rewrite_shebangs).with(OLDER_RUBY_VERSION_BINARY)
       @installer.send(:update_shebangs)
     end
   end
@@ -170,8 +170,8 @@ class InstallerTest < Gem2DebTestCase
       assert_equal true, @installer.send(:all_ruby_versions_supported?)
     end
     should 'know when not all versions are supported' do
-      @installer.stubs(:ruby_versions).returns(['ruby1.9.1'])
-      @installer.stubs(:supported_ruby_versions).returns(['ruby1.9.1', 'rubyX.Y'])
+      @installer.stubs(:ruby_versions).returns([OLDER_RUBY_VERSION])
+      @installer.stubs(:supported_ruby_versions).returns([OLDER_RUBY_VERSION, 'rubyX.Y'])
       assert_equal false, @installer.send(:all_ruby_versions_supported?)
     end
   end
diff --git a/test/unit/setup_rb_installer_test.rb b/test/unit/setup_rb_installer_test.rb
index 17e5fdb..5a423b1 100644
--- a/test/unit/setup_rb_installer_test.rb
+++ b/test/unit/setup_rb_installer_test.rb
@@ -15,9 +15,7 @@ class SetupRbInstallerTest < Gem2DebTestCase
   package = "ruby-simplesetuprb"
 
   context 'installing native extension with setuprb' do
-    [
-     '1.9.1',
-    ].each do |version_number|
+    SUPPORTED_VERSION_NUMBERS.each do |version_number|
       vendorarchdir = VENDOR_ARCH_DIRS['ruby' + version_number]
       target_so = "#{vendorarchdir}/simplesetuprb.so"
       should "install native extension for Ruby #{version_number} for #{package}" do

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gem2deb.git



More information about the Pkg-ruby-extras-commits mailing list