[DRE-commits] [gem2deb] 05/07: refactor test_suite creation in dh_make_ruby

Cédric Boutillier boutil at moszumanska.debian.org
Thu Aug 21 21:11:17 UTC 2014


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

boutil pushed a commit to branch autopkgtest
in repository gem2deb.

commit 194bf10ed0997aa52a6f2901e7fb6e0b4c8c2716
Author: Cédric Boutillier <boutil at debian.org>
Date:   Thu Aug 21 21:07:44 2014 +0200

    refactor test_suite creation in dh_make_ruby
    
    - do not touch the files if a required file for a test running method is
      found
    - use the rake method if a spec/ directory is found
    - otherwise, look in the gemspec for a list of tests
    - default to the rb method if the two previous failed
---
 bin/gem2deb-test-runner     |  2 +-
 lib/gem2deb/dh_make_ruby.rb | 58 +++++++++++++++++++++++++++++++++++++--------
 2 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/bin/gem2deb-test-runner b/bin/gem2deb-test-runner
index e5b51a2..b035116 100755
--- a/bin/gem2deb-test-runner
+++ b/bin/gem2deb-test-runner
@@ -30,7 +30,7 @@ if $PROGRAM_NAME == __FILE__
     exit(1)
   end
 
-  runner = Gem2Deb::TestRunner.detect
+  runner = Gem2Deb::TestRunner.detect!
   runner.autopkgtest = autopkgtest
   runner.run_tests
 end
diff --git a/lib/gem2deb/dh_make_ruby.rb b/lib/gem2deb/dh_make_ruby.rb
index dd6b162..dda07f9 100644
--- a/lib/gem2deb/dh_make_ruby.rb
+++ b/lib/gem2deb/dh_make_ruby.rb
@@ -18,6 +18,7 @@
 require 'gem2deb'
 require 'yaml'
 require 'gem2deb/metadata'
+require 'gem2deb/test_runner'
 require 'rubygems'
 require 'fileutils'
 require 'erb'
@@ -295,30 +296,67 @@ module Gem2Deb
     end
 
     def test_suite
+      if !Gem2Deb::TestRunner.detect
+        test_suite_rspec or test_suite_yaml or test_suite_rb
+      end
+    end
+
+    def test_suite_rspec
+      if File::directory?("spec")
+        write_if_missing("debian/ruby-tests.rake") do |f|
+          f.puts <<-EOF
+# FIXME
+# there's a rspec/ directory in the upstream source.
+# The recommended way to run the RSpec suite is via a rake task.
+# The following commands are enough in many cases and can be adapted to other
+# situations.
+#
+# require 'rspec/core/rake_task'
+#
+# RSpec::Core::RakeTask.new(:spec) do |spec|
+#  spec.pattern      = './spec/*_spec.rb'
+# end
+#
+# task :default => :spec
+        EOF
+        end
+      else
+        false
+      end
+    end
+
+
+    def test_suite_yaml
       if !metadata.test_files.empty?
         write_if_missing("debian/ruby-test-files.yaml") do |f|
           YAML::dump(metadata.test_files, f)
         end
       else
-        if File::directory?("test") or File::directory?("spec")
-          write_if_missing("debian/ruby-tests.rb") do |f|
-            f.puts <<-EOF
+        false
+      end
+    end
+
+    def test_suite_rb
+      if File::directory?("test")
+        write_if_missing("debian/ruby-tests.rb") do |f|
+          f.puts <<-EOF
 # FIXME
-# there's a spec/ or a test/ directory in the upstream source, but
+# there's a test/ directory in the upstream source, but
 # no test suite was defined in the Gem specification. It would be
 # a good idea to define it here so the package gets tested at build time.
 # Examples:
-# $: << 'lib' << '.'
-# Dir['{spec,test}/**/*.rb'].each { |f| require f }
+# $: << './test/'
+# Dir['./test/**/*.rb'].each { |f| require f }
 #
-# require 'test/ts_foo.rb'
+# require './test/ts_foo.rb'
 #
 # require 'rbconfig'
-# ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
+# ruby = ENV['RUBY_TEST_BIN']
 # exec("\#{ruby} -I. test/runtests.rb")
-            EOF
-          end
+        EOF
         end
+      else
+        false
       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