mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 05:57:54 +00:00
parallel: fixup to pass testsuite. Passes testsuite.
This commit is contained in:
parent
e2cf6fdd0a
commit
1f3af83d66
|
@ -1,3 +1,5 @@
|
||||||
|
Test with first argument == END_OF_FILE string
|
||||||
|
|
||||||
unittest til xapply og uden.
|
unittest til xapply og uden.
|
||||||
|
|
||||||
parallel echo {1} {2} {3} ::: a b c :::: myfile ::: X Y
|
parallel echo {1} {2} {3} ::: a b c :::: myfile ::: X Y
|
||||||
|
|
94
src/parallel
94
src/parallel
|
@ -3411,7 +3411,7 @@ sub number_of_replacements {
|
||||||
my %count = ();
|
my %count = ();
|
||||||
my $sum = 0;
|
my $sum = 0;
|
||||||
my $cmd = $command;
|
my $cmd = $command;
|
||||||
my $multi_regexp = multi_regexp();
|
my $multi_regexp = multi_regexp();
|
||||||
my $replacement_regexp =
|
my $replacement_regexp =
|
||||||
"(?:".
|
"(?:".
|
||||||
'\{\d+/?\.?\}'. # {n}, {n.} {n/.} {n/}
|
'\{\d+/?\.?\}'. # {n}, {n.} {n/.} {n/}
|
||||||
|
@ -3949,19 +3949,30 @@ sub nest_get {
|
||||||
# Initialize @::arg_matrix with one arg from each file
|
# Initialize @::arg_matrix with one arg from each file
|
||||||
# read one line from each file
|
# read one line from each file
|
||||||
my @first_arg_set;
|
my @first_arg_set;
|
||||||
|
my $all_empty = 1;
|
||||||
for (my $fhno = 0; $fhno < $no_of_inputs ; $fhno++) {
|
for (my $fhno = 0; $fhno < $no_of_inputs ; $fhno++) {
|
||||||
$::arg_matrix[$fhno][0]=read_arg_from_fh($self->{'fhs'}[$fhno]);
|
my $arg = read_arg_from_fh($self->{'fhs'}[$fhno]);
|
||||||
|
if(defined $arg) {
|
||||||
|
$all_empty = 0;
|
||||||
|
}
|
||||||
|
$::arg_matrix[$fhno][0] = $arg || Arg->new("");
|
||||||
push @first_arg_set, $::arg_matrix[$fhno][0];
|
push @first_arg_set, $::arg_matrix[$fhno][0];
|
||||||
}
|
}
|
||||||
$self->unget([@first_arg_set]);
|
if($all_empty) {
|
||||||
|
# All filehandles were at eof or eof-string
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
return [@first_arg_set];
|
||||||
}
|
}
|
||||||
for (my $fhno = $no_of_inputs - 1; $fhno >= 0; $fhno--) {
|
for (my $fhno = $no_of_inputs - 1; $fhno >= 0; $fhno--) {
|
||||||
if(eof($self->{'fhs'}[$fhno])) {
|
if(eof($self->{'fhs'}[$fhno])) {
|
||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
# read one
|
# read one
|
||||||
|
my $arg = read_arg_from_fh($self->{'fhs'}[$fhno])
|
||||||
|
|| next; # If we just read an EOF string: Treat this as EOF
|
||||||
my $len = $#{$::arg_matrix[$fhno]} + 1;
|
my $len = $#{$::arg_matrix[$fhno]} + 1;
|
||||||
$::arg_matrix[$fhno][$len]=read_arg_from_fh($self->{'fhs'}[$fhno]);
|
$::arg_matrix[$fhno][$len] = $arg;
|
||||||
# make all new combinations
|
# make all new combinations
|
||||||
my @combarg = ();
|
my @combarg = ();
|
||||||
for (my $fhn = 0; $fhn < $no_of_inputs; $fhn++) {
|
for (my $fhn = 0; $fhn < $no_of_inputs; $fhn++) {
|
||||||
|
@ -3986,8 +3997,8 @@ sub nest_get {
|
||||||
return shift @{$self->{'unget'}};
|
return shift @{$self->{'unget'}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# all are eof; return undef
|
# all are eof or at EOF string; return from the unget queue
|
||||||
return undef;
|
return shift @{$self->{'unget'}};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub read_arg_from_fh {
|
sub read_arg_from_fh {
|
||||||
|
@ -3997,44 +4008,47 @@ sub read_arg_from_fh {
|
||||||
# undef if end of file
|
# undef if end of file
|
||||||
my $fh = shift;
|
my $fh = shift;
|
||||||
my $prepend = undef;
|
my $prepend = undef;
|
||||||
loop:
|
my $arg;
|
||||||
if(eof($fh)) {
|
do {{
|
||||||
|
if(eof($fh)) {
|
||||||
|
if(defined $prepend) {
|
||||||
|
return Arg->new($prepend);
|
||||||
|
} else {
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$arg = <$fh>;
|
||||||
|
::debug("read $arg\n");
|
||||||
|
# Remove delimiter
|
||||||
|
$arg =~ s:$/$::;
|
||||||
|
if($Global::end_of_file_string and
|
||||||
|
$arg eq $Global::end_of_file_string) {
|
||||||
|
# Ignore the rest of input file
|
||||||
|
while (<$fh>) {}
|
||||||
|
::debug("EOF-string $arg\n");
|
||||||
|
if(defined $prepend) {
|
||||||
|
return Arg->new($prepend);
|
||||||
|
} else {
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(defined $prepend) {
|
if(defined $prepend) {
|
||||||
return Arg->new($prepend);
|
$arg = $prepend.$arg; # For line continuation
|
||||||
} else {
|
$prepend = undef; #undef;
|
||||||
return undef;
|
|
||||||
}
|
}
|
||||||
}
|
if($Global::ignore_empty) {
|
||||||
my $arg = <$fh>;
|
if($arg =~ /^\s*$/) {
|
||||||
# Remove delimiter
|
redo; # Try the next line
|
||||||
$arg =~ s:$/$::;
|
}
|
||||||
if($Global::end_of_file_string and
|
|
||||||
$arg eq $Global::end_of_file_string) {
|
|
||||||
# Ignore the rest of input file
|
|
||||||
while (<$fh>) {}
|
|
||||||
::debug("EOF-string $arg\n");
|
|
||||||
if(defined $prepend) {
|
|
||||||
return Arg->new($prepend);
|
|
||||||
} else {
|
|
||||||
return undef;
|
|
||||||
}
|
}
|
||||||
}
|
if($Global::max_lines) {
|
||||||
if(defined $prepend) {
|
if($arg =~ /\s$/) {
|
||||||
$arg = $prepend.$arg; # For line continuation
|
# Trailing space => continued on next line
|
||||||
$prepend = undef; #undef;
|
$prepend = $arg;
|
||||||
}
|
redo;
|
||||||
if($Global::ignore_empty) {
|
}
|
||||||
if($arg =~ /^\s*$/) {
|
|
||||||
redo; # Try the next line
|
|
||||||
}
|
}
|
||||||
}
|
}} while (1 == 0); # Dummy loop for redo
|
||||||
if($Global::max_lines) {
|
|
||||||
if($arg =~ /\s$/) {
|
|
||||||
# Trailing space => continued on next line
|
|
||||||
$prepend = $arg;
|
|
||||||
redo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(defined $arg) {
|
if(defined $arg) {
|
||||||
return Arg->new($arg);
|
return Arg->new($arg);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -190,7 +190,7 @@ stdout ssh $SERVER1 ls '/tmp/parallel.file*' || echo OK
|
||||||
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
||||||
|
|
||||||
echo '### --transfer --cleanup - multiple argument files'
|
echo '### --transfer --cleanup - multiple argument files'
|
||||||
parallel -kv --transfer --cleanup -Sparallel@$SERVER2 cat {2} {1} :::: /tmp/test17rel <(sort -r /tmp/test17abs)
|
parallel --xapply -kv --transfer --cleanup -Sparallel@$SERVER2 cat {2} {1} :::: /tmp/test17rel <(sort -r /tmp/test17abs)
|
||||||
# Should give: No such file or directory
|
# Should give: No such file or directory
|
||||||
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
||||||
|
|
||||||
|
|
|
@ -2,53 +2,53 @@
|
||||||
|
|
||||||
echo '### Test ::::'
|
echo '### Test ::::'
|
||||||
echo '### Change --arg-file-sep'
|
echo '### Change --arg-file-sep'
|
||||||
parallel --arg-file-sep :::: -k echo {1} {2} :::: <(seq 1 10) <(seq 5 15)
|
parallel --xapply --arg-file-sep :::: -k echo {1} {2} :::: <(seq 1 10) <(seq 5 15)
|
||||||
parallel --arg-file-sep .--- -k echo {1} {2} .--- <(seq 1 10) <(seq 5 15)
|
parallel --xapply --arg-file-sep .--- -k echo {1} {2} .--- <(seq 1 10) <(seq 5 15)
|
||||||
parallel --argfilesep :::: -k echo {1} {2} :::: <(seq 1 10) <(seq 5 15)
|
parallel --xapply --argfilesep :::: -k echo {1} {2} :::: <(seq 1 10) <(seq 5 15)
|
||||||
parallel --argfilesep .--- -k echo {1} {2} .--- <(seq 1 10) <(seq 5 15)
|
parallel --xapply --argfilesep .--- -k echo {1} {2} .--- <(seq 1 10) <(seq 5 15)
|
||||||
|
|
||||||
echo '### Test xapply --max-replace-args'
|
echo '### Test xapply --max-replace-args'
|
||||||
seq 0 7 | parallel -k --max-replace-args=3 echo {3} {2} {1}
|
seq 0 7 | parallel --xapply -k --max-replace-args=3 echo {3} {2} {1}
|
||||||
echo '### Test -N'
|
echo '### Test -N'
|
||||||
seq 1 5 | parallel -kN3 echo {1} {2} {3}
|
seq 1 5 | parallel --xapply -kN3 echo {1} {2} {3}
|
||||||
echo '### Test -N with 0'
|
echo '### Test -N with 0'
|
||||||
seq 0 7 | parallel -kN3 echo {1} {2} {3}
|
seq 0 7 | parallel --xapply -kN3 echo {1} {2} {3}
|
||||||
echo '### Test :::: on nonexistent'
|
echo '### Test :::: on nonexistent'
|
||||||
stdout parallel -k echo {1} {2} {3} :::: nonexistent
|
stdout parallel --xapply -k echo {1} {2} {3} :::: nonexistent
|
||||||
echo '### Test :::: two files'
|
echo '### Test :::: two files'
|
||||||
parallel -k echo {1} {2} :::: <(seq 1 10) <(seq 5 15)
|
parallel --xapply -k echo {1} {2} :::: <(seq 1 10) <(seq 5 15)
|
||||||
echo '### Test -d, ::::'
|
echo '### Test -d, ::::'
|
||||||
parallel -kd, 'echo a{1} {2}b' :::: <(echo 1,2,3,) <(echo 5,6,7,8)
|
parallel --xapply -kd, 'echo a{1} {2}b' :::: <(echo 1,2,3,) <(echo 5,6,7,8)
|
||||||
echo '### Test -d, :::: one file too much'
|
echo '### Test -d, :::: one file too much'
|
||||||
parallel -kd, echo 'a{1}' '{2}b' :::: <(echo 1,2,3,) <(echo 5,6,7,8) <(echo 9,0)
|
parallel --xapply -kd, echo 'a{1}' '{2}b' :::: <(echo 1,2,3,) <(echo 5,6,7,8) <(echo 9,0)
|
||||||
echo '### Bug: did not quote'
|
echo '### Bug: did not quote'
|
||||||
parallel echo {1} {2} :::: <(echo '>') <(echo b)
|
parallel --xapply echo {1} {2} :::: <(echo '>') <(echo b)
|
||||||
echo '### Quote test triplet 1'
|
echo '### Quote test triplet 1'
|
||||||
parallel -kv :::: <(echo 'echo a'; echo 'echo b')
|
parallel --xapply -kv :::: <(echo 'echo a'; echo 'echo b')
|
||||||
parallel -kv -a <(echo 'echo a'; echo 'echo b')
|
parallel --xapply -kv -a <(echo 'echo a'; echo 'echo b')
|
||||||
(echo 'echo a'; echo 'echo b') | parallel -kv
|
(echo 'echo a'; echo 'echo b') | parallel --xapply -kv
|
||||||
echo '### Quote test triplet 2'
|
echo '### Quote test triplet 2'
|
||||||
parallel -kv echo :::: <(echo 'echo a'; echo 'echo b')
|
parallel --xapply -kv echo :::: <(echo 'echo a'; echo 'echo b')
|
||||||
parallel -kv -a <(echo 'echo a'; echo 'echo b') echo
|
parallel --xapply -kv -a <(echo 'echo a'; echo 'echo b') echo
|
||||||
(echo 'echo a'; echo 'echo b') | parallel -kv echo
|
(echo 'echo a'; echo 'echo b') | parallel --xapply -kv echo
|
||||||
echo '### Quoting if there is a command and 2 arg files'
|
echo '### Quoting if there is a command and 2 arg files'
|
||||||
parallel -kv echo :::: <(echo 'echo a') <(echo 'echo b')
|
parallel --xapply -kv echo :::: <(echo 'echo a') <(echo 'echo b')
|
||||||
echo '### Quoting if there is a command and 2 arg files of uneven length'
|
echo '### Quoting if there is a command and 2 arg files of uneven length'
|
||||||
parallel -kv echo :::: <(echo 'echo a';echo a1) <(echo 'echo b')
|
parallel --xapply -kv echo :::: <(echo 'echo a';echo a1) <(echo 'echo b')
|
||||||
echo '### Quoting if there is no command and 2 arg files'
|
echo '### Quoting if there is no command and 2 arg files'
|
||||||
parallel -kv :::: <(echo 'echo a') <(echo 'echo b')
|
parallel --xapply -kv :::: <(echo 'echo a') <(echo 'echo b')
|
||||||
echo '### Quoting if there is no command and 2 arg files of uneven length'
|
echo '### Quoting if there is no command and 2 arg files of uneven length'
|
||||||
parallel -kv :::: <(echo 'echo a';echo echo a1) <(echo 'echo b')
|
parallel --xapply -kv :::: <(echo 'echo a';echo echo a1) <(echo 'echo b')
|
||||||
|
|
||||||
echo '### Test multiple -a'
|
echo '### Test multiple -a'
|
||||||
parallel -kv -a <(echo a) -a <(echo b) echo {2} {1}
|
parallel --xapply -kv -a <(echo a) -a <(echo b) echo {2} {1}
|
||||||
parallel -kv echo {2} {1} :::: <(echo a) <(echo b)
|
parallel --xapply -kv echo {2} {1} :::: <(echo a) <(echo b)
|
||||||
echo '### Multiple -a: An unused file'
|
echo '### Multiple -a: An unused file'
|
||||||
parallel -kv -a <(echo a) -a <(echo b) -a <(echo c) echo {2} {1}
|
parallel --xapply -kv -a <(echo a) -a <(echo b) -a <(echo c) echo {2} {1}
|
||||||
parallel -kv echo {2} {1} :::: <(echo a) <(echo b) <(echo c)
|
parallel --xapply -kv echo {2} {1} :::: <(echo a) <(echo b) <(echo c)
|
||||||
echo '### Multiple -a: nonexistent'
|
echo '### Multiple -a: nonexistent'
|
||||||
stdout parallel -kv echo {2} {1} :::: nonexist nonexist2
|
stdout parallel --xapply -kv echo {2} {1} :::: nonexist nonexist2
|
||||||
stdout parallel -kv -a nonexist -a nonexist2 echo {2} {1}
|
stdout parallel --xapply -kv -a nonexist -a nonexist2 echo {2} {1}
|
||||||
|
|
||||||
echo '### Test {#.}'
|
echo '### Test {#.}'
|
||||||
parallel -kv -a <(echo a-noext) -a <(echo b-withext.extension) -a <(echo c-ext.gif) echo {3.} {2.} {1.}
|
parallel --xapply -kv -a <(echo a-noext) -a <(echo b-withext.extension) -a <(echo c-ext.gif) echo {3.} {2.} {1.}
|
||||||
|
|
|
@ -39,10 +39,10 @@ printf 'def\tabc\njkl\tghi' | parallel -k --colsep '\t' echo {2} {1}
|
||||||
parallel -k -a <(printf 'def\tabc\njkl\tghi') --colsep '\t' echo {2} {1}
|
parallel -k -a <(printf 'def\tabc\njkl\tghi') --colsep '\t' echo {2} {1}
|
||||||
|
|
||||||
echo '### Test of multiple -a plus colsep'
|
echo '### Test of multiple -a plus colsep'
|
||||||
parallel -k -a <(printf 'def\njkl\n') -a <(printf 'abc\tghi\nmno\tpqr') --colsep '\t' echo {2} {1}
|
parallel --xapply -k -a <(printf 'def\njkl\n') -a <(printf 'abc\tghi\nmno\tpqr') --colsep '\t' echo {2} {1}
|
||||||
|
|
||||||
echo '### Test of multiple -a no colsep'
|
echo '### Test of multiple -a no colsep'
|
||||||
parallel -k -a <(printf 'ghi\npqr\n') -a <(printf 'abc\tdef\njkl\tmno') echo {2} {1}
|
parallel --xapply -k -a <(printf 'ghi\npqr\n') -a <(printf 'abc\tdef\njkl\tmno') echo {2} {1}
|
||||||
|
|
||||||
echo '### Test of quoting after colsplit'
|
echo '### Test of quoting after colsplit'
|
||||||
parallel --colsep % echo {2} {1} ::: '>/dev/null%>/tmp/null'
|
parallel --colsep % echo {2} {1} ::: '>/dev/null%>/tmp/null'
|
||||||
|
|
|
@ -32,7 +32,7 @@ chmod 755 /tmp/shebang
|
||||||
|
|
||||||
echo '### Test of #! with 2 files as input'
|
echo '### Test of #! with 2 files as input'
|
||||||
cat >/tmp/shebang <<EOF
|
cat >/tmp/shebang <<EOF
|
||||||
#!/usr/local/bin/parallel -Yrk -a /tmp/123 echo
|
#!/usr/local/bin/parallel -Yrk --xapply -a /tmp/123 echo
|
||||||
A
|
A
|
||||||
B
|
B
|
||||||
C
|
C
|
||||||
|
|
|
@ -23,7 +23,7 @@ echo '### Test -N'
|
||||||
seq 1 5 | parallel -kN3 echo {1} {2} {3}
|
seq 1 5 | parallel -kN3 echo {1} {2} {3}
|
||||||
|
|
||||||
echo '### Test --arg-file-sep with files of different lengths'
|
echo '### Test --arg-file-sep with files of different lengths'
|
||||||
parallel --arg-file-sep :::: -k echo {1} {2} :::: <(seq 1 1) <(seq 3 4)
|
parallel --xapply --arg-file-sep :::: -k echo {1} {2} :::: <(seq 1 1) <(seq 3 4)
|
||||||
|
|
||||||
echo '### Test respect -s'
|
echo '### Test respect -s'
|
||||||
parallel -kvm -IARG -s15 echo ARG ::: 1 22 333 4444 55555 666666 7777777 88888888 999999999
|
parallel -kvm -IARG -s15 echo ARG ::: 1 22 333 4444 55555 666666 7777777 88888888 999999999
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
echo "### Computing length of command line"
|
echo "### Computing length of command line"
|
||||||
seq 1 2 | parallel -k -N2 echo {1} {2}
|
seq 1 2 | parallel -k -N2 echo {1} {2}
|
||||||
parallel -k -a <(seq 11 12) -a <(seq 1 3) echo
|
parallel --xapply -k -a <(seq 11 12) -a <(seq 1 3) echo
|
||||||
parallel -k -C %+ echo '"{1}_{3}_{2}_{4}"' ::: 'a% c %%b' 'a%c% b %d'
|
parallel -k -C %+ echo '"{1}_{3}_{2}_{4}"' ::: 'a% c %%b' 'a%c% b %d'
|
||||||
parallel -k -C %+ echo {4} ::: 'a% c %%b'
|
parallel -k -C %+ echo {4} ::: 'a% c %%b'
|
||||||
|
|
|
@ -192,7 +192,7 @@ stdout ssh $SERVER1 ls '/tmp/parallel.file*' || echo OK
|
||||||
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
||||||
|
|
||||||
echo '### --transfer --cleanup - multiple argument files'
|
echo '### --transfer --cleanup - multiple argument files'
|
||||||
parallel -kv --transfer --cleanup -Sparallel@$SERVER2 cat {2} {1} :::: /tmp/test17rel <(sort -r /tmp/test17abs)
|
parallel -kv --xapply --transfer --cleanup -Sparallel@$SERVER2 cat {2} {1} :::: /tmp/test17rel <(sort -r /tmp/test17abs)
|
||||||
# Should give: No such file or directory
|
# Should give: No such file or directory
|
||||||
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
stdout ssh parallel@$SERVER2 ls '/tmp/parallel.file*' || echo OK
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue