[DRE-commits] [gem2deb] 01/05: gem2deb-test-runner: add option to check for dependencies
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun May 17 13:00:17 UTC 2015
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to branch master
in repository gem2deb.
commit 2866cbfafac08ecb1e9e5b8dfebfc2699c9d7dc3
Author: Antonio Terceiro <terceiro at debian.org>
Date: Sun May 17 09:24:41 2015 -0300
gem2deb-test-runner: add option to check for dependencies
Closes: #785120, #785120
---
bin/gem2deb-test-runner | 39 +++++++++++++++++++++++++++-----------
debian/changelog | 4 ++++
debian/gem2deb-test-runner.install | 1 +
debian/rules | 2 +-
lib/gem2deb/test_runner.rb | 29 ++++++++++++++++++++++------
5 files changed, 57 insertions(+), 18 deletions(-)
diff --git a/bin/gem2deb-test-runner b/bin/gem2deb-test-runner
index 83ab0ff..2859ef4 100755
--- a/bin/gem2deb-test-runner
+++ b/bin/gem2deb-test-runner
@@ -17,24 +17,35 @@
require 'rbconfig'
require 'fileutils'
+require 'optparse'
require 'gem2deb/test_runner'
-if $PROGRAM_NAME == __FILE__
- autopkgtest = false
+options = {}
- if ARGV.length == 1 && ARGV.first == '--autopkgtest'
- autopkgtest = true
- elsif ARGV.length != 0
- puts "usage: #{File.basename($PROGRAM_NAME)} [--autopkgtest]"
- exit(1)
+optparse = OptionParser.new do |opts|
+
+ opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS]"
+ opts.separator 'Options:'
+
+ opts.on('--autopkgtest', 'Runs tests against the installed package') do
+ options[:autopkgtest] = true
+ end
+
+ opts.on('-c', '--check-dependencies', 'Check dependencies') do
+ options[:check_dependencies] = true
end
- runner = Gem2Deb::TestRunner.detect!
- runner.autopkgtest = autopkgtest
- runner.run_tests
end
+optparse.parse!
+
+runner = Gem2Deb::TestRunner.detect!
+options.each do |opt,value|
+ runner.send("#{opt}=", value)
+end
+runner.run_tests
+
__END__
=head1 NAME
@@ -69,7 +80,13 @@ automatic as-installed package testing, through the autopkgtest framework.
=item B<--autopkgtest>
Run the tests against the installed package for automatic as-installed package
-testing. Useful in conjonction with B<adt-run>(1).
+testing. Useful in conjunction with B<adt-run>(1).
+
+=item B<-c>, B<--check-dependencies>
+
+Before running the tests, checks whether all dependencies of the package, as
+declared in the Rubygems metadata, are present. Makes the program exit with a
+non-zero status code (i.e. fails) if they aren't.
=back
diff --git a/debian/changelog b/debian/changelog
index 7fe6800..6ef61e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,10 @@ gem2deb (0.17) UNRELEASED; urgency=medium
- when acting on an existing source package, read the source package name
from debian/changelog.
- always create test suite files to make dh-make-ruby idempotent
+ * gem2deb-test-runner:
+ - add -c/--check-dependencies to check for dependencies (as declared in
+ the Rubygems metadata, not as declared in debian/control) before running
+ the tests (Closes: #785120, #785120)
-- Antonio Terceiro <terceiro at debian.org> Sat, 16 May 2015 22:51:18 -0300
diff --git a/debian/gem2deb-test-runner.install b/debian/gem2deb-test-runner.install
index d284b38..7d59126 100644
--- a/debian/gem2deb-test-runner.install
+++ b/debian/gem2deb-test-runner.install
@@ -1,3 +1,4 @@
bin/gem2deb-test-runner /usr/bin/
lib/gem2deb/rake/testtask.rb /usr/lib/ruby/vendor_ruby/gem2deb/rake
+lib/gem2deb/metadata.rb.rb /usr/lib/ruby/vendor_ruby/gem2deb
lib/gem2deb/test_runner.rb /usr/lib/ruby/vendor_ruby/gem2deb
diff --git a/debian/rules b/debian/rules
index 215819e..720a8e1 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,7 +11,7 @@ override_dh_auto_build: $(ruby_versions)
mv man/gem2deb/gem2deb-test-runner.1 man/gem2deb-test-runner
override_dh_install:
- dh_install -pgem2deb -Xgem2deb-test-runner -Xtest_runner.rb -Xtesttask.rb
+ dh_install -pgem2deb -Xgem2deb-test-runner -Xtest_runner.rb -Xmetadata.rb -Xtesttask.rb
dh_install -pgem2deb-test-runner
.PHONY: $(ruby_versions)
diff --git a/lib/gem2deb/test_runner.rb b/lib/gem2deb/test_runner.rb
index 9867983..16941f9 100644
--- a/lib/gem2deb/test_runner.rb
+++ b/lib/gem2deb/test_runner.rb
@@ -16,12 +16,15 @@
require 'rbconfig'
require 'fileutils'
+require 'gem2deb/metadata'
+
module Gem2Deb
class TestRunner
include FileUtils::Verbose
attr_accessor :autopkgtest
+ attr_accessor :check_dependencies
def load_path
if self.autopkgtest
@@ -48,8 +51,22 @@ module Gem2Deb
dirs
end
- # Override in subclasses
def run_tests
+ if check_dependencies
+ do_check_dependencies
+ end
+ do_run_tests
+ end
+
+ def do_check_dependencies
+ metadata = Gem2Deb::Metadata.new('.')
+ if metadata.gemspec
+ run_ruby '-e', 'gem "%s"' % metadata.name
+ end
+ end
+
+ # Override in subclasses
+ def do_run_tests
end
# override in subclasses
@@ -124,10 +141,10 @@ module Gem2Deb
def required_file
'debian/ruby-test-files.yaml'
end
- def run_tests
+ def do_run_tests
puts "Running tests for #{rubyver} with test file list from debian/ruby-test-files.yaml ..."
run_ruby(
- '-ryaml',
+ '-ryaml',
'-e',
'YAML.load_file("debian/ruby-test-files.yaml").each { |f| require f }'
)
@@ -138,7 +155,7 @@ module Gem2Deb
def required_file
'debian/ruby-tests.rake'
end
- def run_tests
+ def do_run_tests
puts "Running tests for #{rubyver} using debian/ruby-tests.rake ..."
run_ruby(
'-rrake',
@@ -152,7 +169,7 @@ module Gem2Deb
def required_file
'debian/ruby-tests.rb'
end
- def run_tests
+ def do_run_tests
puts "Running tests for #{rubyver} using debian/ruby-tests.rb..."
ENV['RUBY_TEST_VERSION'] = rubyver
ENV['RUBY_TEST_BIN'] = ruby_binary
@@ -164,7 +181,7 @@ module Gem2Deb
def required_file
'debian/rules'
end
- def run_tests
+ def do_run_tests
puts "Running tests for #{rubyver}: found no way to run a test suite!"
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