File: gem2deb-test-runner

package info (click to toggle)
gem2deb 0.33.1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 992 kB
  • sloc: ruby: 4,942; perl: 81; ansic: 66; makefile: 35; sh: 33
file content (135 lines) | stat: -rwxr-xr-x 3,874 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/ruby

# 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(
    '-d', '--check-dependencies-only',
    "Check dependencies, and don't run tests"
  ) do
    options[:check_dependencies] = true
    options[:check_dependencies_only] = 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.

If you want to check dependencies during the build, you can add something like
this to debian/rules:

=item B<-d>, B<--check-dependencies-only>

Exit after checking dependencies, i.e. only check dependencies, and don't run
any tests. Implies B<--check-dependencies>.

=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 SEE ALSO

L<B<dh_ruby>>(1), L<B<gem2deb>>(1)