Fixed bug #38354: -J profile_name should read from pwd/profile_name before ~/.parallel/profile_name

This commit is contained in:
Ole Tange 2013-03-03 13:45:31 +01:00
parent fc883b4be6
commit d5fa05b425
5 changed files with 87 additions and 76 deletions

View file

@ -1014,9 +1014,13 @@ sub read_options {
# --profile overrides default profiles # --profile overrides default profiles
@profiles = (); @profiles = ();
for my $profile (@opt::profile) { for my $profile (@opt::profile) {
if(-r $profile) {
push @profiles, $profile;
} else {
push @profiles, $ENV{'HOME'}."/.parallel/".$profile; push @profiles, $ENV{'HOME'}."/.parallel/".$profile;
} }
} }
}
for my $profile (@profiles) { for my $profile (@profiles) {
if(-r $profile) { if(-r $profile) {
open (my $in_fh, "<", $profile) || ::die_bug("read-profile: $profile"); open (my $in_fh, "<", $profile) || ::die_bug("read-profile: $profile");

View file

@ -839,9 +839,9 @@ B<--progress> on a running GNU B<parallel> process.
See also: B<--eta> See also: B<--eta>
=item B<--max-args>=I<max-args> =item B<--max-args>=I<max-args> (alpha testing)
=item B<-n> I<max-args> =item B<-n> I<max-args> (alpha testing)
Use at most I<max-args> arguments per command line. Fewer than Use at most I<max-args> arguments per command line. Fewer than
I<max-args> arguments will be used if the size (see the B<-s> option) I<max-args> arguments will be used if the size (see the B<-s> option)
@ -854,9 +854,9 @@ line.
Implies B<-X> unless B<-m> is set. Implies B<-X> unless B<-m> is set.
=item B<--max-replace-args>=I<max-args> =item B<--max-replace-args>=I<max-args> (alpha testing)
=item B<-N> I<max-args> =item B<-N> I<max-args> (alpha testing)
Use at most I<max-args> arguments per command line. Like B<-n> but Use at most I<max-args> arguments per command line. Like B<-n> but
also makes replacement strings B<{1}> .. B<{>I<max-args>B<}> that also makes replacement strings B<{1}> .. B<{>I<max-args>B<}> that
@ -873,8 +873,7 @@ B<tr ':' '\n' < /etc/passwd | parallel -N7 chown {1} {6}>
Implies B<-X> unless B<-m> or B<--pipe> is set. Implies B<-X> unless B<-m> or B<--pipe> is set.
When used with B<--pipe> B<-N> is the number of records to read. This When used with B<--pipe> B<-N> is the number of records to read. This
is much slower than B<--block> so avoid it if performance is is somewhat slower than B<--block>.
important.
=item B<--max-line-length-allowed> =item B<--max-line-length-allowed>

View file

@ -895,11 +895,11 @@ By sending GNU @strong{parallel} SIGUSR2 you can toggle turning on/off
See also: @strong{--eta} See also: @strong{--eta}
@item @strong{--max-args}=@emph{max-args} @item @strong{--max-args}=@emph{max-args} (alpha testing)
@anchor{@strong{--max-args}=@emph{max-args}} @anchor{@strong{--max-args}=@emph{max-args} (alpha testing)}
@item @strong{-n} @emph{max-args} @item @strong{-n} @emph{max-args} (alpha testing)
@anchor{@strong{-n} @emph{max-args}} @anchor{@strong{-n} @emph{max-args} (alpha testing)}
Use at most @emph{max-args} arguments per command line. Fewer than Use at most @emph{max-args} arguments per command line. Fewer than
@emph{max-args} arguments will be used if the size (see the @strong{-s} option) @emph{max-args} arguments will be used if the size (see the @strong{-s} option)
@ -911,11 +911,11 @@ line.
Implies @strong{-X} unless @strong{-m} is set. Implies @strong{-X} unless @strong{-m} is set.
@item @strong{--max-replace-args}=@emph{max-args} @item @strong{--max-replace-args}=@emph{max-args} (alpha testing)
@anchor{@strong{--max-replace-args}=@emph{max-args}} @anchor{@strong{--max-replace-args}=@emph{max-args} (alpha testing)}
@item @strong{-N} @emph{max-args} @item @strong{-N} @emph{max-args} (alpha testing)
@anchor{@strong{-N} @emph{max-args}} @anchor{@strong{-N} @emph{max-args} (alpha testing)}
Use at most @emph{max-args} arguments per command line. Like @strong{-n} but Use at most @emph{max-args} arguments per command line. Like @strong{-n} but
also makes replacement strings @strong{@{1@}} .. @strong{@{}@emph{max-args}@strong{@}} that also makes replacement strings @strong{@{1@}} .. @strong{@{}@emph{max-args}@strong{@}} that
@ -932,8 +932,7 @@ This will set the owner of the homedir to the user:
Implies @strong{-X} unless @strong{-m} or @strong{--pipe} is set. Implies @strong{-X} unless @strong{-m} or @strong{--pipe} is set.
When used with @strong{--pipe} @strong{-N} is the number of records to read. This When used with @strong{--pipe} @strong{-N} is the number of records to read. This
is much slower than @strong{--block} so avoid it if performance is is somewhat slower than @strong{--block}.
important.
@item @strong{--max-line-length-allowed} @item @strong{--max-line-length-allowed}
@anchor{@strong{--max-line-length-allowed}} @anchor{@strong{--max-line-length-allowed}}

View file

@ -2,10 +2,39 @@
# -L1 will join lines ending in ' ' # -L1 will join lines ending in ' '
cat <<'EOF' | parallel -j10 -k -L1 cat <<'EOF' | parallel -j10 -k -L1
echo '### bug #38354: -J profile_name should read from `pwd`/profile_name before ~/.parallel/profile_name'
echo "echo echo from ./local_test_profile" > local_test_profile;
parallel --profile local_test_profile echo ::: 1;
rm local_test_profile
echo "### Test --delay" echo "### Test --delay"
seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.57 true {} 2>&1 | seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.57 true {} 2>&1 |
perl -ne '$_ > 5 and print "More than 5 secs: OK\n"' perl -ne '$_ > 5 and print "More than 5 secs: OK\n"'
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{#} 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
echo "bug #37694: Empty string argument skipped when using --quote"
parallel -q --nonall perl -le 'print scalar @ARGV' 'a' 'b' ''
echo '### Test -k 5'; echo '### Test -k 5';
sleep 5 sleep 5
@ -35,17 +64,14 @@ seq 1 10 | parallel -j 1 echo | sort
seq 1 10 | parallel -j 2 echo | sort seq 1 10 | parallel -j 2 echo | sort
seq 1 10 | parallel -j 3 echo | sort seq 1 10 | parallel -j 3 echo | sort
echo "bug #37694: Empty string argument skipped when using --quote"
parallel -q --nonall perl -le 'print scalar @ARGV' 'a' 'b' ''
echo "bug #37956: --colsep does not default to '\t' as specified in the man page." echo "bug #37956: --colsep does not default to '\t' as specified in the man page."
printf "A\tB\n1\tone" | parallel --header : echo {B} {A} printf "A\tB\n1\tone" | parallel --header : echo {B} {A}
echo '### Test --tollef' echo '### Test --tollef'
parallel -k --tollef echo -- 1 2 3 ::: a b c | sort stdout parallel -k --tollef echo -- 1 2 3 ::: a b c | sort
echo '### Test --tollef --gnu' echo '### Test --tollef --gnu'
parallel -k --tollef --gnu echo ::: 1 2 3 -- a b c stdout parallel -k --tollef --gnu echo ::: 1 2 3 -- a b c
echo '### Test --gnu' echo '### Test --gnu'
parallel -k --gnu echo ::: 1 2 3 -- a b c parallel -k --gnu echo ::: 1 2 3 -- a b c
@ -109,31 +135,10 @@ echo '### -k -i -0'
echo '### -k -0 -i repl' echo '### -k -0 -i repl'
printf '1\0002\0003\0004\0005\000' | stdout parallel -k -0 -i repl echo repl OK printf '1\0002\0003\0004\0005\000' | stdout parallel -k -0 -i repl echo repl OK
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 '### Negative replacement strings' echo '### Negative replacement strings'
parallel -X -j1 -N 6 echo {-1}orrec{1} ::: t B X D E c 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 -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 '{2} + {4} = {2} + {-1}=' '$(( {2} + {-1} ))' ::: "1 2 3 4"
parallel --colsep ' ' echo '{-3}orrect' ::: "1 c 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 EOF

View file

@ -1,5 +1,40 @@
### bug #38354: -J profile_name should read from `pwd`/profile_name before ~/.parallel/profile_name
echo from ./local_test_profile echo 1
### Test --delay ### Test --delay
More than 5 secs: OK More than 5 secs: OK
### test --sshdelay
OK
### 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
### --resume -k
job0id
job1id
job2id
job3id
job0id
job5id
try 2 = nothing
two extra
job6id
job7id
bug #37694: Empty string argument skipped when using --quote
3
### Test -k 5 ### Test -k 5
### Test -k 3 ### Test -k 3
### Test -k 4 ### Test -k 4
@ -46,8 +81,6 @@ d
7 7
8 8
9 9
bug #37694: Empty string argument skipped when using --quote
3
bug #37956: --colsep does not default to '\t' as specified in the man page. bug #37956: --colsep does not default to '\t' as specified in the man page.
one 1 one 1
### Test --tollef ### Test --tollef
@ -58,6 +91,8 @@ one 1
a a
b b
c c
parallel: Warning: See: http://lists.gnu.org/archive/html/parallel/2013-02/msg00018.html
parallel: Warning: YOU ARE USING --tollef. --tollef is obsolete and will be retired 20140222.
### Test --tollef --gnu ### Test --tollef --gnu
1 1
2 2
@ -197,39 +232,8 @@ OK
3 OK 3 OK
4 OK 4 OK
5 OK 5 OK
### test --sshdelay
OK
### Negative replacement strings ### Negative replacement strings
correct correct
correct correct
2 + 4 = 2 + 4= 6 2 + 4 = 2 + 4= 6
correct 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
### --resume -k
job0id
job1id
job2id
job3id
job0id
job5id
try 2 = nothing
two extra
job6id
job7id