diff --git a/t/needs.t b/t/needs.t index c720119a8..0518ba689 100644 --- a/t/needs.t +++ b/t/needs.t @@ -23,6 +23,34 @@ use Rex::Commands; 1; } +{ + package Nested::Module; + + use strict; + use warnings; + + use Rex::Commands; + + task "test", sub { + open( my $fh, ">", "test.txt" ); + close($fh); + }; +} + +{ + package Rex::Module; + + use strict; + use warnings; + + use Rex::Commands; + + task "test", sub { + open( my $fh, ">", "test.txt" ); + close($fh); + }; +} + task "test", sub { needs MyTest; @@ -62,9 +90,31 @@ task "test4", sub { close($fh); }; +task "test5", sub { + needs Nested::Module "test"; + + if ( -f "test.txt" ) { + unlink("test.txt"); + return 1; + } + + die; +}; + +task "test6", sub { + needs Rex::Module "test"; + + if ( -f "test.txt" ) { + unlink("test.txt"); + return 1; + } + + die; +}; + my $task_list = Rex::TaskList->create; my $run_list = Rex::RunList->instance; -$run_list->parse_opts(qw/test test2 test3/); +$run_list->parse_opts(qw/test test2 test3 test5 test6/); for my $task ( $run_list->tasks ) { $task_list->run($task);