1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
#!/usr/bin/ruby -EUTF-8
# Copyright © 2011, Lucas Nussbaum <lucas@debian.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'rbconfig'
require 'fileutils'
require 'optparse'
require 'shellwords'
require 'gem2deb/test_runner'
options = {}
if ENV['GEM2DEB_TEST_RUNNER']
opts = Shellwords.split(ENV['GEM2DEB_TEST_RUNNER'])
ARGV.unshift(*opts)
end
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
opts.on(
'-b', '--check-bundler',
"Check loading the package under bundler"
) do
options[:check_bundler] = true
end
end
optparse.parse!
runner = Gem2Deb::TestRunner.detect!
options.each do |opt,value|
runner.send("#{opt}=", value)
end
runner.run_tests
__END__
=head1 NAME
gem2deb-test-runner - runs test suite contained in Debian Ruby packages
=head1 SYNOPSIS
B<gem2deb-test-runner> [B<OPTIONS>]
=head1 DESCRIPTION
B<gem2deb-test-runner> runs the tests shipped inside a source Debian Ruby
package. The way the tests are run is configured in one of the three files:
I<debian/ruby-test-files.yaml>, I<debian/ruby-tests.rake>,
I<debian/ruby-tests.rb>. See the B<FILES> section in B<dh_ruby>(1) for details.
If called without argument in the root of the source package after the package
is built and installed under debian/I<package_name>, then the tests will be run
using the files of the package installed under debian/I<package_name>. This call
is part of the B<dh_ruby>(1) sequence when building a Ruby package with gem2deb.
If the option B<--autopkgtest> is used, the package needs to be installed on
the system. B<gem2deb-test-runner> will not try to load files under debian/ and
will move away temporarily the lib/ and ext/ directory to ensure the test
suite is run against the installed package. This is used in the context of
automatic as-installed package testing, through the autopkgtest framework.
=head1 OPTIONS
=over
=item B<--autopkgtest>
Run the tests against the installed package for automatic as-installed package
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.
=item B<-b>, B<--check-bundler>
Check that the package can be correctly loaded by bundler. This tests that the
package can be loaded properly by bundler with the following two types of
Gemfiles. One lists the package as a top-level dependency:
gem "foo"
This will be tested by calling `B<ruby -rbundler/setup>`.
The other type includes the package in a group:
group :test do
gem "foo"
end
That will be tested by calling `B<ruby -rbundler -e 'Bundler.require(:test)'>`.
=back
=head1 ENVIRONMENT
=over
=item GEM2DEB_TEST_RUNNER
Used to pass options to gem2deb-test-runner via the environment. For example,
to make gem2deb-test-runner check dependencies during package build, you can
add the following to I<debian/rules>:
=over
export GEM2DEB_TEST_RUNNER = --check-dependencies
=back
=back
=head1 EXIT STATUS
=over
=item
0 if tests pass.
=item
1 if tests fail.
=item
77 if B<--autopkgtest> was passed and B<gem2deb-test-runner> cannot determine
how to run the test suite.
=back
=head1 SEE ALSO
L<B<dh_ruby>>(1), L<B<gem2deb>>(1)
|