From cf38b9078c1de0211529f455d2373fbfccafd84c Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 13 Feb 2013 01:15:37 +0100 Subject: [PATCH] parallel: --keep-order --resume-failed works. --- src/parallel | 11 ++++--- testsuite/tests-to-run/parallel-local164.sh | 33 +++++++++++---------- testsuite/wanted-results/parallel-local164 | 23 ++++++++++++++ 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/parallel b/src/parallel index 6fb75e60..6a087782 100755 --- a/src/parallel +++ b/src/parallel @@ -500,7 +500,7 @@ sub options_hash { "resume-failed|resumefailed" => \$opt::resume_failed, "silent" => \$opt::silent, #"silent-error|silenterror" => \$opt::silent_error, - "keep-order|keeporder|k" => \$opt::k, + "keep-order|keeporder|k" => \$opt::keeporder, "group" => \$opt::group, "g" => \$opt::retired, "ungroup|u" => \$opt::u, @@ -674,7 +674,7 @@ sub parse_options { $Global::debug = (defined $opt::D); if(defined $opt::X) { $Global::ContextReplace = 1; } if(defined $opt::silent) { $Global::verbose = 0; } - if(defined $opt::k) { $Global::keeporder = 1; } + if(defined $opt::keeporder) { $Global::keeporder = 1; } if(defined $opt::group) { $Global::grouped = 1; } if(defined $opt::u) { $Global::grouped = 0; } if(defined $opt::0) { $/ = "\0"; } @@ -1858,8 +1858,11 @@ sub reaper { $Private::job_end_sequence ||= 1; debug("Looking for: $Private::job_end_sequence ". "Current: ".$job->seq()."\n"); - while($Private::print_later{$Private::job_end_sequence}) { + while($Private::print_later{$Private::job_end_sequence} + or + vec($Global::job_already_run,$Private::job_end_sequence,1)) { debug("Found job end $Private::job_end_sequence"); + defined $Private::print_later{$Private::job_end_sequence} and $Private::print_later{$Private::job_end_sequence}->print(); delete $Private::print_later{$Private::job_end_sequence}; $Private::job_end_sequence++; @@ -4070,7 +4073,7 @@ sub print { my $err = $self->stderr(); my $command = $self->sshlogin_wrap(); - if($Global::joblog and not $self->virgin()) { + if($Global::joblog and not ($opt::pipe and $self->virgin())) { my $cmd; if($Global::verbose <= 1) { $cmd = $self->replaced(); diff --git a/testsuite/tests-to-run/parallel-local164.sh b/testsuite/tests-to-run/parallel-local164.sh index 9ae789c6..9db99c2f 100644 --- a/testsuite/tests-to-run/parallel-local164.sh +++ b/testsuite/tests-to-run/parallel-local164.sh @@ -112,27 +112,28 @@ echo '### -k -0 -i repl' echo '### test --sshdelay' stdout /usr/bin/time -f %e parallel -j0 --sshdelay 0.5 -S localhost true ::: 1 2 3 | perl -ne 'print($_ > 1.80 ? "OK\n" : "Not OK\n")' -echo '### bug #38299: --resume-failed -k' - rm /tmp/joblog-38299 - parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#}id{}\;exit {} ::: 0 1 2 3 0 1 - echo try 2 - parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#}id{}\;exit {} ::: 0 1 2 3 0 1 - echo with exit 0 - parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#}id{}\;exit 0 ::: 0 1 2 3 0 1 - -echo '### --resume -k' - rm -f /tmp/joblog-resume - parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5 - echo try 2 = nothing - parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5 - echo two extra - parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit 0 ::: 0 1 2 3 0 5 6 7 - echo '### Negative replacement strings' parallel -X -j1 -N 6 echo {-1}orrec{1} ::: t B X D E c parallel -N 6 echo {-1}orrect ::: A B X D E c parallel --colsep ' ' echo '{2} + {4} = {2} + {-1}=' '$(( {2} + {-1} ))' ::: "1 2 3 4" parallel --colsep ' ' echo '{-3}orrect' ::: "1 c 3 4" +echo '### bug #38299: --resume-failed -k'; + rm /tmp/joblog-38299; + parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit {} ::: 0 1 2 3 0 1; + echo try 2. Gives failing - not 0; + parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit {} ::: 0 1 2 3 0 1; + echo with exit 0; + parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit 0 ::: 0 1 2 3 0 1; + echo try 2 again. Gives empty; + parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit {} ::: 0 1 2 3 0 1 + +echo '### --resume -k'; + rm -f /tmp/joblog-resume; + parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5; + echo try 2 = nothing; + parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5; + echo two extra; + parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit 0 ::: 0 1 2 3 0 5 6 7 EOF diff --git a/testsuite/wanted-results/parallel-local164 b/testsuite/wanted-results/parallel-local164 index 3ab39dbd..74d622d8 100644 --- a/testsuite/wanted-results/parallel-local164 +++ b/testsuite/wanted-results/parallel-local164 @@ -199,3 +199,26 @@ OK 5 OK ### test --sshdelay OK +### Negative replacement strings +correct +correct +2 + 4 = 2 + 4= 6 +correct +### bug #38299: --resume-failed -k +job1 val 0 +job2 val 1 +job3 val 2 +job4 val 3 +job5 val 0 +job6 val 1 +try 2. Gives failing - not 0 +job2 val 1 +job3 val 2 +job4 val 3 +job6 val 1 +with exit 0 +job2 val 1 +job3 val 2 +job4 val 3 +job6 val 1 +try 2 again. Gives empty