]> git.donarmstrong.com Git - debhelper.git/blob - dh_auto_test
dh_auto_clean: New program, automates running make clean (or distclean, or realclean...
[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                 # Make --question returns false if the target is
48                 # up-to-date. But we still want to run the target in this
49                 # case. So ceck if a target exists by seeing if make outputs
50                 # "Making target".
51                 my $ret=`LANG=C $ENV{MAKE} --question $target 2>/dev/null`;
52                 chomp $ret;
53                 if ($ret =~ /^Making \Q$target\E/m) {
54                         doit($ENV{MAKE}, $target, @{$dh{U_PARAMS}});
55                         last;
56                 }
57         }
58 }
59
60 =head1 SEE ALSO
61
62 L<debhelper(7)>
63
64 This program is a part of debhelper.
65
66 =head1 AUTHOR
67
68 Joey Hess <joeyh@debian.org>
69
70 =cut