parallel: bug #37849: --results should create subdirs. With test.

This commit is contained in:
Ole Tange 2012-12-03 23:28:10 +01:00
parent 59a1d67b59
commit 22a9ac5390
3 changed files with 68 additions and 61 deletions

View file

@ -26,6 +26,8 @@ use POSIX qw(:sys_wait_h setsid ceil :errno_h);
use Symbol qw(gensym); use Symbol qw(gensym);
# tempfile used in Job::start # tempfile used in Job::start
use File::Temp qw(tempfile tempdir); use File::Temp qw(tempfile tempdir);
# mkpath used in openresultsfile
use File::Path;
# GetOptions used in get_options_from_array # GetOptions used in get_options_from_array
use Getopt::Long; use Getopt::Long;
# Used to ensure code quality # Used to ensure code quality
@ -3268,15 +3270,20 @@ sub seq {
sub openresultsfile { sub openresultsfile {
my $self = shift; my $self = shift;
my $args_as_filename = $self->{'commandline'}->args_as_filename(); my $args_as_dirname = $self->{'commandline'}->args_as_dirname();
my ($outfh,$errfh,$name); my ($outfh,$errfh,$name,$dir);
$name = $opt::results."stdout\t".$args_as_filename; # prefix/name1/val1/name2/val2/
$dir = $opt::results."/".$args_as_dirname;
File::Path::mkpath($dir);
# prefix/name1/val1/name2/val2/stdout
$name = "$dir/stdout";
if(not open($outfh,"+>",$name)) { if(not open($outfh,"+>",$name)) {
::error("Cannot write to `$name'.\n"); ::error("Cannot write to `$name'.\n");
::wait_and_exit(255); ::wait_and_exit(255);
} }
$self->set_stdoutfilename($name); $self->set_stdoutfilename($name);
$name = $opt::results."stderr\t".$args_as_filename; # prefix/name1/val1/name2/val2/stderr
$name = "$dir/stderr";
if(not open($errfh,"+>",$name)) { if(not open($errfh,"+>",$name)) {
::error("Cannot write to `$name'.\n"); ::error("Cannot write to `$name'.\n");
::wait_and_exit(255); ::wait_and_exit(255);
@ -4283,9 +4290,9 @@ sub args_as_string {
map { @$_ } @{$self->{'arg_list'}}); map { @$_ } @{$self->{'arg_list'}});
} }
sub args_as_filename { sub args_as_dirname {
# Returns: # Returns:
# all unmodified arguments joined with '\t' (similar to {}) # all unmodified arguments joined with '/' (similar to {})
# \t \0 \\ and / are quoted # \t \0 \\ and / are quoted
my $self = shift; my $self = shift;
my @res = (); my @res = ();
@ -4309,7 +4316,7 @@ sub args_as_filename {
$rec_ref->[$n-1]->orig()); $rec_ref->[$n-1]->orig());
} }
} }
return join "\t", @res; return join "/", @res;
} }
sub len { sub len {

View file

@ -53,31 +53,31 @@ echo "bug #34958: --pipe with record size measured in lines";
echo "### Test --results"; echo "### Test --results";
mkdir -p /tmp/parallel_results_test; mkdir -p /tmp/parallel_results_test;
parallel -k --results /tmp/parallel_results_test/testA echo {1} {2} ::: I II ::: III IIII; parallel -k --results /tmp/parallel_results_test/testA echo {1} {2} ::: I II ::: III IIII;
ls /tmp/parallel_results_test/testA*; rm /tmp/parallel_results_test/testA* ls /tmp/parallel_results_test/testA/*/*/*/*/*; rm -rf /tmp/parallel_results_test/testA*
echo "### Test --res"; echo "### Test --res";
mkdir -p /tmp/parallel_results_test; mkdir -p /tmp/parallel_results_test;
parallel -k --results /tmp/parallel_results_test/testD echo {1} {2} ::: I II ::: III IIII; parallel -k --res /tmp/parallel_results_test/testD echo {1} {2} ::: I II ::: III IIII;
ls /tmp/parallel_results_test/testD*; rm /tmp/parallel_results_test/testD* ls /tmp/parallel_results_test/testD/*/*/*/*/*; rm -rf /tmp/parallel_results_test/testD*
echo "### Test --result"; echo "### Test --result";
mkdir -p /tmp/parallel_results_test; mkdir -p /tmp/parallel_results_test;
parallel -k --result /tmp/parallel_results_test/testE echo {1} {2} ::: I II ::: III IIII; parallel -k --result /tmp/parallel_results_test/testE echo {1} {2} ::: I II ::: III IIII;
ls /tmp/parallel_results_test/testE*; rm /tmp/parallel_results_test/testE* ls /tmp/parallel_results_test/testE/*/*/*/*/*; rm -rf /tmp/parallel_results_test/testE*
echo "### Test --results --header :"; echo "### Test --results --header :";
mkdir -p /tmp/parallel_results_test; mkdir -p /tmp/parallel_results_test;
parallel -k --header : --results /tmp/parallel_results_test/testB echo {1} {2} ::: a I II ::: b III IIII; parallel -k --header : --results /tmp/parallel_results_test/testB echo {1} {2} ::: a I II ::: b III IIII;
ls /tmp/parallel_results_test/testB*; rm /tmp/parallel_results_test/testB* ls /tmp/parallel_results_test/testB/*/*/*/*/*; rm -rf /tmp/parallel_results_test/testB*
echo "### Test --results --header : named"; echo "### Test --results --header : named - a/b swapped";
mkdir -p /tmp/parallel_results_test; mkdir -p /tmp/parallel_results_test;
parallel -k --header : --results /tmp/parallel_results_test/testC echo {a} {b} ::: a I II ::: b III IIII; parallel -k --header : --results /tmp/parallel_results_test/testC echo {a} {b} ::: b III IIII ::: a I II;
ls /tmp/parallel_results_test/testC*; rm /tmp/parallel_results_test/testC* ls /tmp/parallel_results_test/testC/*/*/*/*/*; rm -rf /tmp/parallel_results_test/testC*
echo "### Test --results --header : piped"; echo "### Test --results --header : piped";
mkdir -p /tmp/parallel_results_test; mkdir -p /tmp/parallel_results_test;
(echo Col; perl -e 'print "backslash\\tab\tslash/null\0eof\n"') | parallel --header : --result /tmp/parallel_results_test/testF_ true; (echo Col; perl -e 'print "backslash\\tab\tslash/null\0eof\n"') | parallel --header : --result /tmp/parallel_results_test/testF true;
ls /tmp/parallel_results_test/testF*; rm /tmp/parallel_results_test/testF* ls /tmp/parallel_results_test/testF/*/*/*; rm -rf /tmp/parallel_results_test/testF*
EOF EOF

View file

@ -140,66 +140,66 @@ I III
I IIII I IIII
II III II III
II IIII II IIII
/tmp/parallel_results_test/testAstderr 1 I 2 III /tmp/parallel_results_test/testA/1/I/2/III/stderr
/tmp/parallel_results_test/testAstderr 1 I 2 IIII /tmp/parallel_results_test/testA/1/I/2/III/stdout
/tmp/parallel_results_test/testAstderr 1 II 2 III /tmp/parallel_results_test/testA/1/I/2/IIII/stderr
/tmp/parallel_results_test/testAstderr 1 II 2 IIII /tmp/parallel_results_test/testA/1/I/2/IIII/stdout
/tmp/parallel_results_test/testAstdout 1 I 2 III /tmp/parallel_results_test/testA/1/II/2/III/stderr
/tmp/parallel_results_test/testAstdout 1 I 2 IIII /tmp/parallel_results_test/testA/1/II/2/III/stdout
/tmp/parallel_results_test/testAstdout 1 II 2 III /tmp/parallel_results_test/testA/1/II/2/IIII/stderr
/tmp/parallel_results_test/testAstdout 1 II 2 IIII /tmp/parallel_results_test/testA/1/II/2/IIII/stdout
### Test --res ### Test --res
I III I III
I IIII I IIII
II III II III
II IIII II IIII
/tmp/parallel_results_test/testDstderr 1 I 2 III /tmp/parallel_results_test/testD/1/I/2/III/stderr
/tmp/parallel_results_test/testDstderr 1 I 2 IIII /tmp/parallel_results_test/testD/1/I/2/III/stdout
/tmp/parallel_results_test/testDstderr 1 II 2 III /tmp/parallel_results_test/testD/1/I/2/IIII/stderr
/tmp/parallel_results_test/testDstderr 1 II 2 IIII /tmp/parallel_results_test/testD/1/I/2/IIII/stdout
/tmp/parallel_results_test/testDstdout 1 I 2 III /tmp/parallel_results_test/testD/1/II/2/III/stderr
/tmp/parallel_results_test/testDstdout 1 I 2 IIII /tmp/parallel_results_test/testD/1/II/2/III/stdout
/tmp/parallel_results_test/testDstdout 1 II 2 III /tmp/parallel_results_test/testD/1/II/2/IIII/stderr
/tmp/parallel_results_test/testDstdout 1 II 2 IIII /tmp/parallel_results_test/testD/1/II/2/IIII/stdout
### Test --result ### Test --result
I III I III
I IIII I IIII
II III II III
II IIII II IIII
/tmp/parallel_results_test/testEstderr 1 I 2 III /tmp/parallel_results_test/testE/1/I/2/III/stderr
/tmp/parallel_results_test/testEstderr 1 I 2 IIII /tmp/parallel_results_test/testE/1/I/2/III/stdout
/tmp/parallel_results_test/testEstderr 1 II 2 III /tmp/parallel_results_test/testE/1/I/2/IIII/stderr
/tmp/parallel_results_test/testEstderr 1 II 2 IIII /tmp/parallel_results_test/testE/1/I/2/IIII/stdout
/tmp/parallel_results_test/testEstdout 1 I 2 III /tmp/parallel_results_test/testE/1/II/2/III/stderr
/tmp/parallel_results_test/testEstdout 1 I 2 IIII /tmp/parallel_results_test/testE/1/II/2/III/stdout
/tmp/parallel_results_test/testEstdout 1 II 2 III /tmp/parallel_results_test/testE/1/II/2/IIII/stderr
/tmp/parallel_results_test/testEstdout 1 II 2 IIII /tmp/parallel_results_test/testE/1/II/2/IIII/stdout
### Test --results --header : ### Test --results --header :
I III I III
I IIII I IIII
II III II III
II IIII II IIII
/tmp/parallel_results_test/testBstderr a I b III /tmp/parallel_results_test/testB/a/I/b/III/stderr
/tmp/parallel_results_test/testBstderr a I b IIII /tmp/parallel_results_test/testB/a/I/b/III/stdout
/tmp/parallel_results_test/testBstderr a II b III /tmp/parallel_results_test/testB/a/I/b/IIII/stderr
/tmp/parallel_results_test/testBstderr a II b IIII /tmp/parallel_results_test/testB/a/I/b/IIII/stdout
/tmp/parallel_results_test/testBstdout a I b III /tmp/parallel_results_test/testB/a/II/b/III/stderr
/tmp/parallel_results_test/testBstdout a I b IIII /tmp/parallel_results_test/testB/a/II/b/III/stdout
/tmp/parallel_results_test/testBstdout a II b III /tmp/parallel_results_test/testB/a/II/b/IIII/stderr
/tmp/parallel_results_test/testBstdout a II b IIII /tmp/parallel_results_test/testB/a/II/b/IIII/stdout
### Test --results --header : named ### Test --results --header : named - a/b swapped
I III I III
II III II III
I IIII I IIII
II IIII II IIII
/tmp/parallel_results_test/testCstderr a I b III /tmp/parallel_results_test/testC/a/I/b/III/stderr
/tmp/parallel_results_test/testCstderr a I b IIII /tmp/parallel_results_test/testC/a/I/b/III/stdout
/tmp/parallel_results_test/testCstderr a II b III /tmp/parallel_results_test/testC/a/I/b/IIII/stderr
/tmp/parallel_results_test/testCstderr a II b IIII /tmp/parallel_results_test/testC/a/I/b/IIII/stdout
/tmp/parallel_results_test/testCstdout a I b III /tmp/parallel_results_test/testC/a/II/b/III/stderr
/tmp/parallel_results_test/testCstdout a I b IIII /tmp/parallel_results_test/testC/a/II/b/III/stdout
/tmp/parallel_results_test/testCstdout a II b III /tmp/parallel_results_test/testC/a/II/b/IIII/stderr
/tmp/parallel_results_test/testCstdout a II b IIII /tmp/parallel_results_test/testC/a/II/b/IIII/stdout
### Test --results --header : piped ### Test --results --header : piped
/tmp/parallel_results_test/testF_stderr Col backslash\\tab\tslash\_null\0eof /tmp/parallel_results_test/testF/Col/backslash\\tab\tslash\_null\0eof/stderr
/tmp/parallel_results_test/testF_stdout Col backslash\\tab\tslash\_null\0eof /tmp/parallel_results_test/testF/Col/backslash\\tab\tslash\_null\0eof/stdout