]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_test
Merge branch 'master' of ssh://git.debian.org/git/debhelper/debhelper
[debhelper.git] / dh_auto_test
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_auto_test - automatically runs a package's test suites
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_auto_test> [S<I<debhelper options>>] [S<B<--> I<params>>]
15
16 =head1 DESCRIPTION
17
18 dh_auto_test is a debhelper program that tries to automatically run a
19 package's test suite. If there's a Makefile and it contains a "test"
20 or "check" target, then this is  done by running make (or MAKE, if the
21 environment variable is set). If the test suite fails, the command will
22 exit nonzero. If there's no test suite, it will exit zero without doing
23 anything.
24
25 This is intended to work for about 90% of packages with a test suite. If it
26 doesn't work, you're encouraged to skip using dh_auto_test at all, and
27 just run the test suite manually.
28
29 =head1 OPTIONS
30
31 =over 4
32
33 =item B<--> I<params>
34
35 Pass "params" to the program that is run. These can be used to supplement
36 or override the any standard parameters that dh_auto_test passes.
37
38 =back
39
40 =head1 NOTES
41
42 If the DEB_BUILD_OPTIONS environment variable contains "nocheck", no
43 tests will be performed.
44
45 =cut
46
47 init();
48
49 if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nocheck/) {
50         exit 0;
51 }
52
53 if (-e "Makefile" || -e "makefile" || -e "GNUmakefile") {
54         $ENV{MAKE}="make" unless exists $ENV{MAKE};
55         foreach my $target (qw{test check}) {
56                 # Use make -n to check to see if the target would do
57                 # anything. There's no good way to test if a target exists.
58                 my $ret=`$ENV{MAKE} -s -n $target 2>/dev/null`;
59                 chomp $ret;
60                 if (length $ret) {
61                         doit($ENV{MAKE}, $target, @{$dh{U_PARAMS}});
62                         last;
63                 }
64         }
65 }
66 elsif (-e "Build.PL" && -e "Build") {
67         $ENV{MODULEBUILDRC} = "/dev/null";
68         doit(qw/perl Build test/, @{$dh{U_PARAMS}});
69 }
70
71 =head1 SEE ALSO
72
73 L<debhelper(7)>
74
75 This program is a part of debhelper.
76
77 =head1 AUTHOR
78
79 Joey Hess <joeyh@debian.org>
80
81 =cut