|
plan tests => 3;
my $project_path = path( $Bin , 'data' , 'chapter3_multi_test' );
my $results_path = path( $project_path , 'amcpresults' );
my $am = Algorithm::AM->new(
$project_path ,
-commas => 'no' ,
-repeat => 2,
);
my @record ;
my @args ;
push @args , ( "-$_" , record_hook( $_ ))
for qw(
beginhook
begintesthook
beginrepeathook
datahook
endrepeathook
endtesthook
endhook
) ;
sub record_hook {
my ( $hook_name ) = @_ ;
return sub {
push @record , $hook_name ;
};
}
$am ->classify( @args );
my @expected = (
q(beginhook) ,
(
qw(
begintesthook
beginrepeathook
) ,
qw(datahook) x 5,
qw(
endrepeathook
beginrepeathook
) ,
qw(datahook) x 5,
qw(
endrepeathook
endtesthook
)
) x 2,
q(endhook)
);
is_deeply(\ @record , \ @expected , 'hooks called in expected order' )
or note explain \ @record ;
unlink $results_path
if -e $results_path ;
$am ->classify(
-datahook => sub {
my ( $index ) = @_ ;
return $index ;
},
-repeat => 1,
-gangs => 'yes' ,
);
my $results = read_file( $results_path );
like_string( $results , qr/Total Excluded:\s+1/ , 'False datahook return excludes item' );
unlike_string( $results , qr/3 1 0/ , 'item specified by datahook is not present in output' );
unlink $results_path
if -e $results_path ;
|