Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix needs with nested namespaces (fix #1188) #1189

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Rex/Commands.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,9 @@ sub needs {

Rex::Logger::debug("need to call tasks from $self");

$self =~ s/^Rex:://g;
$self =~ s/::/:/g;

my @tasks_to_run;
if($self) {
@tasks_to_run = $tl->get_all_tasks(qr{^\Q$self\E:[A-Za-z0-9_\-]+$});
Expand Down
52 changes: 51 additions & 1 deletion t/needs.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down