[DRE-commits] [gem2deb] 07/08: autopkgtest support for Ruby packages
Antonio Terceiro
terceiro at moszumanska.debian.org
Mon Feb 10 16:06:27 UTC 2014
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to branch master
in repository gem2deb.
commit 4c961efe8c549e5f05a444c776cde5f54ba4e3de
Author: Antonio Terceiro <terceiro at debian.org>
Date: Mon Feb 10 11:40:15 2014 -0300
autopkgtest support for Ruby packages
Pending: extract the test runner into a proper binary in a standalone
binary package to minimize dependencies for test suites.
---
lib/gem2deb/test_runner.rb | 60 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 51 insertions(+), 9 deletions(-)
diff --git a/lib/gem2deb/test_runner.rb b/lib/gem2deb/test_runner.rb
index 5b4a730..1b04539 100644
--- a/lib/gem2deb/test_runner.rb
+++ b/lib/gem2deb/test_runner.rb
@@ -14,11 +14,24 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'rbconfig'
+require 'fileutils'
module Gem2Deb
class TestRunner
+ include FileUtils::Verbose
+
+ attr_accessor :autopkgtest
+
+ def initialize
+ self.autopkgtest = autopkgtest
+ end
+
def load_path
+ if self.autopkgtest
+ return []
+ end
+
# We should only use installation paths for the current Ruby
# version.
#
@@ -60,7 +73,29 @@ module Gem2Deb
puts cmd.map { |part| part =~ /['"]/ ? part.inspect : part }.join(' ')
end
ENV['RUBYLIB'] = (ENV['RUBYLIB'] ? ENV['RUBYLIB'] + ':' : '') + rubylib
- exec(*cmd)
+ if autopkgtest
+ move_away 'lib'
+ move_away 'ext'
+ end
+ system(*cmd)
+ exitstatus = $?.exitstatus
+ if autopkgtest
+ restore 'lib'
+ restore 'ext'
+ end
+ exit(exitstatus)
+ end
+
+ def move_away(dir)
+ if File.exists?(dir)
+ mv dir, '.gem2deb.' + dir
+ end
+ end
+
+ def restore(dir)
+ if File.exists?('.gem2deb.' + dir)
+ mv '.gem2deb.' + dir, dir
+ end
end
def self.inherited(subclass)
@@ -70,13 +105,14 @@ module Gem2Deb
def self.subclasses
@subclasses
end
- def self.detect_and_run
- detect.run_tests
- end
def self.detect
subclasses.map(&:new).find do |runner|
runner.activate?
- end
+ end || bail("E: this tool must be run from inside a Debian source package.")
+ end
+ def self.bail(msg)
+ puts msg
+ exit 1
end
def rubyver
@rubyver ||= RbConfig::CONFIG['ruby_install_name']
@@ -139,11 +175,17 @@ module Gem2Deb
end
if $PROGRAM_NAME == __FILE__
- if ARGV.length == 0
- Gem2Deb::TestRunner.detect_and_run
- else
- puts "usage: #{File.basename($PROGRAM_NAME)}"
+ autopkgtest = false
+
+ if ARGV.length == 1 && ARGV.first == '--autopkgtest'
+ autopkgtest = true
+ elsif ARGV.length != 0
+ puts "usage: #{File.basename($PROGRAM_NAME)} [--autopkgtest]"
exit(1)
end
+
+ runner = Gem2Deb::TestRunner.detect
+ runner.autopkgtest = autopkgtest
+ runner.run_tests
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