da10840a55cad3d294b402f232372783d3c442bd
[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
9 BEGIN {
10   $ENV{HARNESS_OPTIONS} = 'j:c';
11   unshift @INC, 'modules/override';
12   push    @INC, 'modules/fallback';
13 }
14
15 sub find_files_to_test {
16   my @files;
17   File::Find::find(sub { push @files, $File::Find::name if (-f $_) && m/\.t$/ }, 't');
18   return @files;
19 }
20
21 my (@tests_to_run, @tests_to_run_first);
22
23 if (@ARGV) {
24   @tests_to_run       = @ARGV;
25
26 } else {
27   @tests_to_run_first = qw(t/000setup_database.t);
28   my %exclude         = map  { ($_ => 1)     } @tests_to_run_first;
29   @tests_to_run       = grep { !$exclude{$_} } sort(find_files_to_test());
30 }
31
32 if (@tests_to_run_first) {
33   my ($total, $failed) = execute_tests(tests => \@tests_to_run_first);
34   exit(1) unless !$total->{bad} && (0 < $total->{max});
35 }
36
37 runtests(@tests_to_run);