]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_test
new method to tell if a makefile contains a target
[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 encoruaged 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 suppliment
36 or override the any standard parameters that dh_auto_test passes.
37
38 =back
39
40 =cut
41
42 init();
43
44 if (-e "Makefile" || -e "makefile" || -e "GNUmakefile") {
45         $ENV{MAKE}="make" unless exists $ENV{MAKE};
46         foreach my $target (qw{test check}) {
47                 # Use make -n to check to see if the target would do
48                 # anything. There's no good way to test if a target exists.
49                 my $ret=`$ENV{MAKE} -s -n $target 2>/dev/null`;
50                 chomp $ret;
51                 if (length $ret) {
52                         doit($ENV{MAKE}, $target, @{$dh{U_PARAMS}});
53                         last;
54                 }
55         }
56 }
57
58 =head1 SEE ALSO
59
60 L<debhelper(7)>
61
62 This program is a part of debhelper.
63
64 =head1 AUTHOR
65
66 Joey Hess <joeyh@debian.org>
67
68 =cut