epic-s6ts
[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   use FindBin;
12
13   unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
14   push   (@INC, $FindBin::Bin . '/..');                  # '.' will be removed from @INC soon.
15
16   $ENV{HARNESS_OPTIONS} = 'c';
17
18   chdir($FindBin::Bin . '/..');
19 }
20
21 my @exclude_for_fast = (
22   't/001compile.t',
23   't/003safesys.t',
24 );
25
26 sub find_files_to_test {
27   my @files;
28   File::Find::find(sub { push @files, $File::Find::name if (-f $_) && m/\.t$/ }, 't');
29   return @files;
30 }
31
32 my (@tests_to_run, @tests_to_run_first);
33
34 GetOptions(
35   'f|fast' => \ my $fast,
36 );
37
38 if (@ARGV) {
39   @tests_to_run       = @ARGV;
40
41 } else {
42   @tests_to_run_first = qw(t/000setup_database.t);
43   my %exclude         = map  { ($_ => 1)     } @tests_to_run_first, (@exclude_for_fast)x!!$fast;
44   @tests_to_run       = grep { !$exclude{$_} } sort(find_files_to_test());
45 }
46
47 if (@tests_to_run_first) {
48   my ($total, $failed) = execute_tests(tests => \@tests_to_run_first);
49   exit(1) unless !$total->{bad} && (0 < $total->{max});
50 }
51
52 runtests(@tests_to_run);