[DRE-commits] [gem2deb] 01/01: Fix most Ruby warnings

Antonio Terceiro terceiro at moszumanska.debian.org
Sat Jul 1 13:34:53 UTC 2017


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

terceiro pushed a commit to branch master
in repository gem2deb.

commit cb13489947321c82fb8b14c3f0ca896d193927bb
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Fri Jun 30 18:31:29 2017 -0300

    Fix most Ruby warnings
    
    rake 12.0.0 runs the tests with warnings enabled by default, what
    exposed them.
---
 debian/changelog                     |  4 ++++
 lib/gem2deb/metadata.rb              |  1 +
 test/integration/gem2deb_test.rb     |  2 +-
 test/test_helper.rb                  | 12 +++++++-----
 test/unit/dh_make_ruby_test.rb       |  4 ++--
 test/unit/dh_ruby_test.rb            |  4 ++--
 test/unit/installer_test.rb          |  2 +-
 test/unit/setup_rb_installer_test.rb |  2 +-
 8 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index b97e13e..a73545a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,10 @@ gem2deb (0.33.2) UNRELEASED; urgency=medium
   [ Balasankar C ]
   * Change template copyright to Expat (Closes: #786521)
 
+  [ Antonio Terceiro ]
+  * Fix most Ruby warning in the code. They were exposed by rake 12.0.0, which
+    runs tests with warnings enabled by default.
+
  -- Antonio Terceiro <terceiro at debian.org>  Fri, 19 May 2017 10:28:28 -0300
 
 gem2deb (0.33.1) unstable; urgency=medium
diff --git a/lib/gem2deb/metadata.rb b/lib/gem2deb/metadata.rb
index 328b638..46d1fec 100644
--- a/lib/gem2deb/metadata.rb
+++ b/lib/gem2deb/metadata.rb
@@ -27,6 +27,7 @@ module Gem2Deb
     attr_reader :root
 
     def initialize(root)
+      @gemspec = nil
       @source_dir = File.expand_path(root)
       @root = root
       Dir.chdir(source_dir) do
diff --git a/test/integration/gem2deb_test.rb b/test/integration/gem2deb_test.rb
index e8a6b98..e24f974 100644
--- a/test/integration/gem2deb_test.rb
+++ b/test/integration/gem2deb_test.rb
@@ -24,7 +24,7 @@ class Gem2DebTest < Gem2DebTestCase
 
   should 'generate a non-lintian-clean copyright file' do
     changes_file = File.join(self.class.tmpdir, "ruby-simplegem_*.changes")
-    assert_match /E: ruby-simplegem: helper-templates-in-copyright/, `lintian #{changes_file}`
+    assert_match %r/E: ruby-simplegem: helper-templates-in-copyright/, `lintian #{changes_file}`
   end
 
   should 'install executables for altbindir' do
diff --git a/test/test_helper.rb b/test/test_helper.rb
index b3c0e38..ca1fad9 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -14,8 +14,10 @@ require 'gem2deb'
 Gem2Deb.verbose = false
 Gem2Deb.testing = true
 
-Gem2DebTestCase = Test::Unit::TestCase
-class Gem2DebTestCase
+$__gem2deb_tests_cleanup_installed = false
+$environment_setup = false
+
+class Gem2DebTestCase < Test::Unit::TestCase
 
   SUPPORTED_VERSION_NUMBERS = Gem2Deb::RUBY_CONFIG_VERSION.values.sort
   SUPPORTED_API_NUMBERS = Gem2Deb::RUBY_API_VERSION.values.sort
@@ -49,7 +51,7 @@ class Gem2DebTestCase
       one_time_setup_blocks << block
     end
     def one_time_setup?
-      @one_time_setup
+      @one_time_setup ||= nil
     end
     def one_time_setup!
       unless one_time_setup?
@@ -157,7 +159,7 @@ class Gem2DebTestCase
   # make sure that everything that comes from gem2deb has precedence over
   # system-wide installed versions.
   def self.run_command(cmd)
-    if !@environment_setup && !ENV['ADTTMP']
+    if !$environment_setup && !ENV['ADTTMP']
       # setup Perl lib for debhelper7
       perl5lib = File.join(GEM2DEB_ROOT_SOURCE_DIR, 'debhelper7')
 
@@ -166,7 +168,7 @@ class Gem2DebTestCase
       ENV['PATH'] = [File.join(GEM2DEB_ROOT_SOURCE_DIR, 'bin'), File.join(GEM2DEB_ROOT_SOURCE_DIR, 'test', 'bin'), ENV['PATH']].join(':')
       ENV['RUBYLIB'] = File.join(GEM2DEB_ROOT_SOURCE_DIR, 'lib')
 
-      @environment_setup = true
+      $environment_setup = true
     end
 
     @run_command_id ||= -1
diff --git a/test/unit/dh_make_ruby_test.rb b/test/unit/dh_make_ruby_test.rb
index 2db7260..6a1676b 100644
--- a/test/unit/dh_make_ruby_test.rb
+++ b/test/unit/dh_make_ruby_test.rb
@@ -130,10 +130,10 @@ class DhMakeRubyTest < Gem2DebTestCase
       assert_equal 'Fancy_Package', $__fancy_package_dh_make_ruby.gem_name
     end
     should 'use actual upstream name in debian/watch' do
-      assert_match /gemwatch\/Fancy_Package/, File.read(File.join(tmpdir, 'ruby-fancy-package-0.0.1/debian/watch'))
+      assert_match %r/gemwatch\/Fancy_Package/, File.read(File.join(tmpdir, 'ruby-fancy-package-0.0.1/debian/watch'))
     end
     should 'use actual upstream name in debian/copyright' do
-      assert_match /Upstream-Name: Fancy_Package/, File.read(File.join(tmpdir, 'ruby-fancy-package-0.0.1/debian/copyright'))
+      assert_match %r/Upstream-Name: Fancy_Package/, File.read(File.join(tmpdir, 'ruby-fancy-package-0.0.1/debian/copyright'))
     end
   end
 
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index 2a844f4..973ae8f 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -39,7 +39,7 @@ class DhRubyTest < Gem2DebTestCase
       end
       should "link #{target_so} against libruby#{version_number}" do
         installed_so = installed_file_path(SIMPLE_EXTENSION_DIRNAME, "ruby-simpleextension", target_so)
-        assert_match /libruby-?#{version_number}/, `ldd #{installed_so}`
+        assert_match %r/libruby-?#{version_number}/, `ldd #{installed_so}`
       end
     end
   end
@@ -150,7 +150,7 @@ class DhRubyTest < Gem2DebTestCase
       @dh_ruby = Gem2Deb::DhRuby.new
     end
     should 'be debian/${binary_package} by default' do
-      assert_match /debian\/ruby-foo$/, @dh_ruby.send(:destdir_for, 'ruby-foo', 'debian/tmp')
+      assert_match %r/debian\/ruby-foo$/, @dh_ruby.send(:destdir_for, 'ruby-foo', 'debian/tmp')
     end
     should 'install to debian/tmp when DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR is set' do
       saved_env = ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR']
diff --git a/test/unit/installer_test.rb b/test/unit/installer_test.rb
index 66b8c31..878f6fa 100644
--- a/test/unit/installer_test.rb
+++ b/test/unit/installer_test.rb
@@ -93,7 +93,7 @@ class InstallerTest < Gem2DebTestCase
     should 'add a shebang when there is none' do
       lines = File.readlines(self.class.tmpdir + '/rewrite_shebangs/usr/bin/no-shebang')
       assert_match %r{/usr/bin/ruby}, lines[0]
-      assert_match /puts/, lines[1]
+      assert_match %r/puts/, lines[1]
     end
     should 'not rewrite shebangs non-Ruby scripts' do
       lines = File.readlines(self.class.tmpdir + '/rewrite_shebangs/usr/bin/shell-script')
diff --git a/test/unit/setup_rb_installer_test.rb b/test/unit/setup_rb_installer_test.rb
index 8b5be3a..7ba47a5 100644
--- a/test/unit/setup_rb_installer_test.rb
+++ b/test/unit/setup_rb_installer_test.rb
@@ -23,7 +23,7 @@ class SetupRbInstallerTest < Gem2DebTestCase
       end
       should "link #{target_so} against libruby#{version_number} for #{package}" do
         installed_so = installed_file_path(dirname, package, target_so)
-        assert_match /libruby-?#{version_number}/, `ldd #{installed_so}`
+        assert_match %r/libruby-?#{version_number}/, `ldd #{installed_so}`
       end
     end
   end

-- 
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