Hi! As a recreational break, I took a couple of hours to look at how we could add support for autopkgtest [1] in Ruby packages.
I've used ruby-backports as a playground. See the `pu/autopkgtest` branch in the Git repository [2]. [1] http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD [2] http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/ruby-backports.git;a=shortlog;h=refs/heads/pu/autopkgtest Here's some highlihts on the patch: diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..c684055 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,2 @@ +Tests: gem2deb +Depends: gem2deb rake I decided to name the test `gem2deb` because my hope is that we can have the code starting the tests as part as gem2deb. In the specific case of ruby-backports, `ruby-tests.rb` starts the test suite by using rake to launch a target in upstream Rakefile. diff --git a/debian/tests/gem2deb b/debian/tests/gem2deb new file mode 100755 index 0000000..d48b2ed --- /dev/null +++ b/debian/tests/gem2deb @@ -0,0 +1,55 @@ +#!/usr/bin/ruby + +require 'gem2deb/metadata' +require 'gem2deb/dh_ruby' +require 'tmpdir' +require 'fileutils' + +class Tester < Gem2Deb::DhRuby + def run + run_tests + end +end + +unless ENV['ADTTMP'] + $stderr.puts 'ADTTMP is not set. Exiting' + exit 1 +end + +dest = ENV['ADTTMP'] + +unless Dir.entries(dest) == ['.', '..'] + $stderr.puts 'ADTTMP is not empty. Exiting' + exit 1 +end + +# Copy test files +metadata = Gem2Deb::Metadata.new('.') +metadata.test_files.each do |path| + next if File.directory?(path) + FileUtils.mkdir_p File.join(dest, File.dirname(path)) + FileUtils.install path, File.join(dest, path) +end + +# Copy Rakefile if there's one +# XXX: not sure if we need that +FileUtils.cp 'Rakefile', dest if File.exists?('Rakefile') + +# Dump gemspecs in static form (because upstream gemspec might use Git or +# other tools) +Dir.glob('*.gemspec').each do |path| + spec = Gem::Specification.load(path) + File.open(File.join(dest, path), 'w') { |f| f.write(spec.to_ruby) } +end + + +# Copy Debian directory +FileUtils.cp_r 'debian', dest + +# Copy metadata for DhRuby +FileUtils.cp 'metadata.yml', dest + +# Run the tests +Dir.chdir(dest) do + Tester.new.run +end So the idea here is that we use the empty directory that autopkgtest creates for us and populate it with the test files declared in the gemspec. We also copy/generate enough other files so DhRuby is happy to run the tests as dh_ruby usually does. Pretty small, but not the nicest. I also had to patch the upstream test suite because it assumed it was run in the same source tree as the library. Anyone should feel free to take it up from here, I don't think I'll spend more time on this anytime soon. -- Lunar .''`. [email protected] : :Ⓐ : # apt-get install anarchism `. `'` `-
signature.asc
Description: Digital signature
_______________________________________________ Pkg-ruby-extras-maintainers mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ruby-extras-maintainers
