Skip to content

Navigation Menu

Sign in
Sign up

Don't include do_task() results in the summary (fix #851) #855

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

Open
kablamo wants to merge 1 commit into master
base: master
Choose a base branch
Loading
from eric/do-task-summary
Open
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
14 changes: 6 additions & 8 deletions lib/Rex/Commands.pm
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -690,15 +690,13 @@ You may also use an arrayRef for $task if you want to call multiple tasks.
=cut

sub do_task {
my $task = shift;
my $thing = shift;
my @tasks = ref $thing ? @$thing : $thing;
my $current_task = task();

if ( ref($task) eq "ARRAY" ) {
for my $t ( @{$task} ) {
Rex::TaskList->run($t);
}
}
else {
return Rex::TaskList->run($task);
for my $task (@tasks) {
$task->parent($current_task);
Rex::TaskList->run($task);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Rex/Fork/Task.pm
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sub start {
task => $self->{task}->name,
server => $self->{server},
exit_code => $exit_code,
};
} unless $self->{task}->parent;

$self->{'running'} = 0;
exit();
Expand Down
8 changes: 8 additions & 0 deletions lib/Rex/Task.pm
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ sub get_data {
connection_type => $self->{connection_type},
opts => $self->{opts},
args => $self->{args},
parent => $self->{parent},
};
}

Expand Down Expand Up @@ -952,4 +953,11 @@ sub clone {
return Rex::Task->new( %{ $self->get_data } );
}

sub parent {
my ($self, $parent) = @_;
$self->{parent} = $parent if $parent;
return $self->{parent};

}

1;
2 changes: 1 addition & 1 deletion lib/Rex/TaskList/Parallel_ForkManager.pm
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ sub run {
task => $task_name,
server => $server->to_s,
exit_code => $exit_code,
};
} unless $task->parent;

$fm->finish;
}
Expand Down
15 changes: 11 additions & 4 deletions t/summary.t
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ subtest "distributor => 'Base'" => sub {
task1 => { server => '<local>', task => 'task1', exit_code => 0 },
task2 => { server => '<local>', task => 'task2', exit_code => 0 },
task3 => { server => '<local>', task => 'task3', exit_code => 1 },
task4 => { server => '<local>', task => 'task4', exit_code => 1 },
);
};

Expand All @@ -32,6 +33,7 @@ subtest "distributor => 'Base'" => sub {
task1 => { server => '<local>', task => 'task1', exit_code => 2 },
task2 => { server => '<local>', task => 'task2', exit_code => 0 },
task3 => { server => '<local>', task => 'task3', exit_code => 1 },
task4 => { server => '<local>', task => 'task4', exit_code => 1 },
);
};
};
Expand All @@ -49,6 +51,7 @@ SKIP: {
task1 => { server => '<local>', task => 'task1', exit_code => 0 },
task2 => { server => '<local>', task => 'task2', exit_code => 0 },
task3 => { server => '<local>', task => 'task3', exit_code => 1 },
task4 => { server => '<local>', task => 'task4', exit_code => 1 },
);
};

Expand All @@ -60,6 +63,7 @@ SKIP: {
task1 => { server => '<local>', task => 'task1', exit_code => 2 },
task2 => { server => '<local>', task => 'task2', exit_code => 0 },
task3 => { server => '<local>', task => 'task3', exit_code => 1 },
task4 => { server => '<local>', task => 'task4', exit_code => 1 },
);
};
};
Expand All @@ -83,11 +87,14 @@ sub create_tasks {
run $cmd;
};

desc "desc 3";
desc "desc 3"; # test do_task() in a transaction
task "task3" => sub {
transaction {
do_task qw/task0/;
};
transaction { do_task qw/task0/ };
};

desc "desc 4"; # test do_task()
task "task4" => sub {
do_task qw/task0/;
};
}

Expand Down

AltStyle によって変換されたページ (->オリジナル) /