[DRE-commits] [SCM] gem2deb.git branch, master, updated. c850f8ca4a7f25e7b75ae7b4c1d07e89ad1ab051

Antonio Terceiro terceiro at softwarelivre.org
Thu Mar 31 17:29:10 UTC 2011


The following commit has been merged in the master branch:
commit c850f8ca4a7f25e7b75ae7b4c1d07e89ad1ab051
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date:   Thu Mar 31 10:27:21 2011 -0700

    Extract Method Gem2Deb::DhRuby#skip_tests?

diff --git a/lib/gem2deb/dh_ruby.rb b/lib/gem2deb/dh_ruby.rb
index ecd8e1f..b542d5c 100644
--- a/lib/gem2deb/dh_ruby.rb
+++ b/lib/gem2deb/dh_ruby.rb
@@ -131,7 +131,9 @@ module Gem2Deb
     protected
 
     def check_rubygems
-      return if ENV['DEB_BUILD_OPTIONS'] and ENV['DEB_BUILD_OPTIONS'].split(' ').include?('nocheck')
+      if skip_checks?
+        return
+      end
       found = false
       if File::exists?('debian/require-rubygems.overrides')
         overrides = YAML::load_file('debian/require-rubygems.overrides')
@@ -188,8 +190,7 @@ module Gem2Deb
     end
 
     def run_tests(rubyver)
-      if ENV['DEB_BUILD_OPTIONS'] and ENV['DEB_BUILD_OPTIONS'].split(' ').include?('nocheck')
-        puts "DEB_BUILD_OPTIONS include nocheck, skipping test suite."
+      if skip_checks?
         return
       end
       if File::exists?('debian/ruby-test-files.yaml')
@@ -214,6 +215,18 @@ module Gem2Deb
       end
     end
 
+    def skip_checks?
+      if @skip_checks.nil?
+        if ENV['DEB_BUILD_OPTIONS'] && ENV['DEB_BUILD_OPTIONS'].split(' ').include?('nocheck')
+          puts "DEB_BUILD_OPTIONS includes nocheck, skipping all checks (test suite, rubygems usage etc)." if @verbose
+          @skip_checks = true
+        else
+          @skip_checks = false
+        end
+      end
+      @skip_checks
+    end
+
     JUNK_FILES = %w( RCSLOG tags TAGS .make.state .nse_depinfo )
     HOOK_FILES = %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
       %w( config setup install clean ).map {|t| sprintf(fmt, t) }
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index 0a0a7f0..35d78fa 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -62,6 +62,29 @@ class DhRubyTest < Gem2DebTestCase
     end
   end
 
+  context 'skipping checks' do
+    setup do
+      @dh_ruby = Gem2Deb::DhRuby.new
+      @dh_ruby.verbose = false
+    end
+    should 'not skip tests if DEB_BUILD_OPTIONS is not defined' do
+      ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns(nil)
+      assert_equal false, @dh_ruby.send(:skip_checks?)
+    end
+    should 'not skip tests if DEB_BUILD_OPTIONS does not include nocheck' do
+      ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns('nostrip').at_least_once
+      assert_equal false, @dh_ruby.send(:skip_checks?)
+    end
+    should 'skip tests if DEB_BUILD_OPTIONS contains exactly nocheck' do
+      ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns('nocheck').at_least_once
+      assert_equal true, @dh_ruby.send(:skip_checks?)
+    end
+    should 'skip tests if DEB_BUILD_OPTIONS contains nocheck among other options' do
+      ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns('nostrip nocheck noopt').at_least_once
+      assert_equal true, @dh_ruby.send(:skip_checks?)
+    end
+  end
+
   protected
 
   def assert_installed(gem_dirname, package, path)

-- 
gem2deb.git



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