d9fdaf495ea12898e3eb1519f0f3aa83462e6554
[kivitendo-erp.git] / t / test.pl
1 #!/usr/bin/perl -X
2
3 use strict;
4
5 use Data::Dumper;
6 use File::Find ();
7 use Test::Harness qw(runtests execute_tests);
8 use Getopt::Long;
9
10 BEGIN {
11    $ENV{HARNESS_OPTIONS} = 'c';
12   unshift @INC, 'modules/override';
13   push    @INC, 'modules/fallback';
14 }
15
16 my @exclude_for_fast = (
17   't/001compile.t',
18   't/003safesys.t',
19 );
20
21 sub find_files_to_test {
22   my @files;
23   File::Find::find(sub { push @files, $File::Find::name if (-f $_) && m/\.t$/ }, 't');
24   return @files;
25 }
26
27 my (@tests_to_run, @tests_to_run_first);
28
29 GetOptions(
30   'f|fast' => \ my $fast,
31 );
32
33 if (@ARGV) {
34   @tests_to_run       = @ARGV;
35
36 } else {
37   @tests_to_run_first = qw(t/000setup_database.t);
38   my %exclude         = map  { ($_ => 1)     } @tests_to_run_first, (@exclude_for_fast)x!!$fast;
39   @tests_to_run       = grep { !$exclude{$_} } sort(find_files_to_test());
40 }
41
42 if (@tests_to_run_first) {
43   my ($total, $failed) = execute_tests(tests => \@tests_to_run_first);
44   exit(1) unless !$total->{bad} && (0 < $total->{max});
45 }
46
47 runtests(@tests_to_run);