File Coverage

lib/Rex/Test.pm
Criterion Covered Total %
statement 18 19 94.7
branch n/a
condition n/a
subroutine 7 8 87.5
pod 0 1 0.0
total 25 28 89.2


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Test;
6              
7 1     1   13 use v5.12.5;
  1         4  
8 1     1   8 use warnings;
  1         4  
  1         33  
9 1     1   5 use Rex -base;
  1         3  
  1         6  
10 1     1   7 use Data::Dumper;
  1         2  
  1         52  
11 1     1   7 use Rex::Commands::Box;
  1         2  
  1         10  
12             require Rex::CLI;
13              
14             our $VERSION = '1.14.3'; # VERSION
15              
16             BEGIN {
17 1     1   9 use Rex::Shared::Var;
  1         2  
  1         75  
18 1     1   29 share qw(@exit);
19             }
20              
21             Rex::CLI->add_exit(
22             sub {
23             if ( scalar @exit > 0 ) {
24             CORE::exit(1);
25             }
26             }
27             );
28              
29             sub push_exit {
30 0     0 0   push @exit, shift;
31             }
32              
33             desc 'Run tests specified with --test=testfile (default: t/*.t)';
34             task run => make {
35             Rex::Logger::info("Running integration tests...");
36              
37             my $parameters = shift;
38             my @files;
39              
40             LOCAL {
41             @files =
42             defined $parameters->{test} ? glob( $parameters->{test} ) : glob('t/*.t');
43             };
44              
45             for my $file (@files) {
46             Rex::Logger::info("Running test: $file.");
47             do "./$file";
48             Rex::Logger::info( "Error running $file: $@", "error" ) if $@;
49             }
50             };
51              
52             1;