mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 22:17:54 +00:00
parallel: bug #37849: --results should create subdirs. With test.
This commit is contained in:
parent
59a1d67b59
commit
22a9ac5390
21
src/parallel
21
src/parallel
|
@ -26,6 +26,8 @@ use POSIX qw(:sys_wait_h setsid ceil :errno_h);
|
|||
use Symbol qw(gensym);
|
||||
# tempfile used in Job::start
|
||||
use File::Temp qw(tempfile tempdir);
|
||||
# mkpath used in openresultsfile
|
||||
use File::Path;
|
||||
# GetOptions used in get_options_from_array
|
||||
use Getopt::Long;
|
||||
# Used to ensure code quality
|
||||
|
@ -3268,15 +3270,20 @@ sub seq {
|
|||
|
||||
sub openresultsfile {
|
||||
my $self = shift;
|
||||
my $args_as_filename = $self->{'commandline'}->args_as_filename();
|
||||
my ($outfh,$errfh,$name);
|
||||
$name = $opt::results."stdout\t".$args_as_filename;
|
||||
my $args_as_dirname = $self->{'commandline'}->args_as_dirname();
|
||||
my ($outfh,$errfh,$name,$dir);
|
||||
# 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)) {
|
||||
::error("Cannot write to `$name'.\n");
|
||||
::wait_and_exit(255);
|
||||
}
|
||||
$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)) {
|
||||
::error("Cannot write to `$name'.\n");
|
||||
::wait_and_exit(255);
|
||||
|
@ -4283,9 +4290,9 @@ sub args_as_string {
|
|||
map { @$_ } @{$self->{'arg_list'}});
|
||||
}
|
||||
|
||||
sub args_as_filename {
|
||||
sub args_as_dirname {
|
||||
# Returns:
|
||||
# all unmodified arguments joined with '\t' (similar to {})
|
||||
# all unmodified arguments joined with '/' (similar to {})
|
||||
# \t \0 \\ and / are quoted
|
||||
my $self = shift;
|
||||
my @res = ();
|
||||
|
@ -4309,7 +4316,7 @@ sub args_as_filename {
|
|||
$rec_ref->[$n-1]->orig());
|
||||
}
|
||||
}
|
||||
return join "\t", @res;
|
||||
return join "/", @res;
|
||||
}
|
||||
|
||||
sub len {
|
||||
|
|
|
@ -53,31 +53,31 @@ echo "bug #34958: --pipe with record size measured in lines";
|
|||
echo "### Test --results";
|
||||
mkdir -p /tmp/parallel_results_test;
|
||||
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";
|
||||
mkdir -p /tmp/parallel_results_test;
|
||||
parallel -k --results /tmp/parallel_results_test/testD echo {1} {2} ::: I II ::: III IIII;
|
||||
ls /tmp/parallel_results_test/testD*; rm /tmp/parallel_results_test/testD*
|
||||
parallel -k --res /tmp/parallel_results_test/testD echo {1} {2} ::: I II ::: III IIII;
|
||||
ls /tmp/parallel_results_test/testD/*/*/*/*/*; rm -rf /tmp/parallel_results_test/testD*
|
||||
|
||||
echo "### Test --result";
|
||||
mkdir -p /tmp/parallel_results_test;
|
||||
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 :";
|
||||
mkdir -p /tmp/parallel_results_test;
|
||||
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;
|
||||
parallel -k --header : --results /tmp/parallel_results_test/testC echo {a} {b} ::: a I II ::: b III IIII;
|
||||
ls /tmp/parallel_results_test/testC*; rm /tmp/parallel_results_test/testC*
|
||||
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 -rf /tmp/parallel_results_test/testC*
|
||||
|
||||
echo "### Test --results --header : piped";
|
||||
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;
|
||||
ls /tmp/parallel_results_test/testF*; rm /tmp/parallel_results_test/testF*
|
||||
(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 -rf /tmp/parallel_results_test/testF*
|
||||
|
||||
EOF
|
||||
|
|
|
@ -140,66 +140,66 @@ I III
|
|||
I IIII
|
||||
II III
|
||||
II IIII
|
||||
/tmp/parallel_results_test/testAstderr 1 I 2 III
|
||||
/tmp/parallel_results_test/testAstderr 1 I 2 IIII
|
||||
/tmp/parallel_results_test/testAstderr 1 II 2 III
|
||||
/tmp/parallel_results_test/testAstderr 1 II 2 IIII
|
||||
/tmp/parallel_results_test/testAstdout 1 I 2 III
|
||||
/tmp/parallel_results_test/testAstdout 1 I 2 IIII
|
||||
/tmp/parallel_results_test/testAstdout 1 II 2 III
|
||||
/tmp/parallel_results_test/testAstdout 1 II 2 IIII
|
||||
/tmp/parallel_results_test/testA/1/I/2/III/stderr
|
||||
/tmp/parallel_results_test/testA/1/I/2/III/stdout
|
||||
/tmp/parallel_results_test/testA/1/I/2/IIII/stderr
|
||||
/tmp/parallel_results_test/testA/1/I/2/IIII/stdout
|
||||
/tmp/parallel_results_test/testA/1/II/2/III/stderr
|
||||
/tmp/parallel_results_test/testA/1/II/2/III/stdout
|
||||
/tmp/parallel_results_test/testA/1/II/2/IIII/stderr
|
||||
/tmp/parallel_results_test/testA/1/II/2/IIII/stdout
|
||||
### Test --res
|
||||
I III
|
||||
I IIII
|
||||
II III
|
||||
II IIII
|
||||
/tmp/parallel_results_test/testDstderr 1 I 2 III
|
||||
/tmp/parallel_results_test/testDstderr 1 I 2 IIII
|
||||
/tmp/parallel_results_test/testDstderr 1 II 2 III
|
||||
/tmp/parallel_results_test/testDstderr 1 II 2 IIII
|
||||
/tmp/parallel_results_test/testDstdout 1 I 2 III
|
||||
/tmp/parallel_results_test/testDstdout 1 I 2 IIII
|
||||
/tmp/parallel_results_test/testDstdout 1 II 2 III
|
||||
/tmp/parallel_results_test/testDstdout 1 II 2 IIII
|
||||
/tmp/parallel_results_test/testD/1/I/2/III/stderr
|
||||
/tmp/parallel_results_test/testD/1/I/2/III/stdout
|
||||
/tmp/parallel_results_test/testD/1/I/2/IIII/stderr
|
||||
/tmp/parallel_results_test/testD/1/I/2/IIII/stdout
|
||||
/tmp/parallel_results_test/testD/1/II/2/III/stderr
|
||||
/tmp/parallel_results_test/testD/1/II/2/III/stdout
|
||||
/tmp/parallel_results_test/testD/1/II/2/IIII/stderr
|
||||
/tmp/parallel_results_test/testD/1/II/2/IIII/stdout
|
||||
### Test --result
|
||||
I III
|
||||
I IIII
|
||||
II III
|
||||
II IIII
|
||||
/tmp/parallel_results_test/testEstderr 1 I 2 III
|
||||
/tmp/parallel_results_test/testEstderr 1 I 2 IIII
|
||||
/tmp/parallel_results_test/testEstderr 1 II 2 III
|
||||
/tmp/parallel_results_test/testEstderr 1 II 2 IIII
|
||||
/tmp/parallel_results_test/testEstdout 1 I 2 III
|
||||
/tmp/parallel_results_test/testEstdout 1 I 2 IIII
|
||||
/tmp/parallel_results_test/testEstdout 1 II 2 III
|
||||
/tmp/parallel_results_test/testEstdout 1 II 2 IIII
|
||||
/tmp/parallel_results_test/testE/1/I/2/III/stderr
|
||||
/tmp/parallel_results_test/testE/1/I/2/III/stdout
|
||||
/tmp/parallel_results_test/testE/1/I/2/IIII/stderr
|
||||
/tmp/parallel_results_test/testE/1/I/2/IIII/stdout
|
||||
/tmp/parallel_results_test/testE/1/II/2/III/stderr
|
||||
/tmp/parallel_results_test/testE/1/II/2/III/stdout
|
||||
/tmp/parallel_results_test/testE/1/II/2/IIII/stderr
|
||||
/tmp/parallel_results_test/testE/1/II/2/IIII/stdout
|
||||
### Test --results --header :
|
||||
I III
|
||||
I IIII
|
||||
II III
|
||||
II IIII
|
||||
/tmp/parallel_results_test/testBstderr a I b III
|
||||
/tmp/parallel_results_test/testBstderr a I b IIII
|
||||
/tmp/parallel_results_test/testBstderr a II b III
|
||||
/tmp/parallel_results_test/testBstderr a II b IIII
|
||||
/tmp/parallel_results_test/testBstdout a I b III
|
||||
/tmp/parallel_results_test/testBstdout a I b IIII
|
||||
/tmp/parallel_results_test/testBstdout a II b III
|
||||
/tmp/parallel_results_test/testBstdout a II b IIII
|
||||
### Test --results --header : named
|
||||
/tmp/parallel_results_test/testB/a/I/b/III/stderr
|
||||
/tmp/parallel_results_test/testB/a/I/b/III/stdout
|
||||
/tmp/parallel_results_test/testB/a/I/b/IIII/stderr
|
||||
/tmp/parallel_results_test/testB/a/I/b/IIII/stdout
|
||||
/tmp/parallel_results_test/testB/a/II/b/III/stderr
|
||||
/tmp/parallel_results_test/testB/a/II/b/III/stdout
|
||||
/tmp/parallel_results_test/testB/a/II/b/IIII/stderr
|
||||
/tmp/parallel_results_test/testB/a/II/b/IIII/stdout
|
||||
### Test --results --header : named - a/b swapped
|
||||
I III
|
||||
II III
|
||||
I IIII
|
||||
II IIII
|
||||
/tmp/parallel_results_test/testCstderr a I b III
|
||||
/tmp/parallel_results_test/testCstderr a I b IIII
|
||||
/tmp/parallel_results_test/testCstderr a II b III
|
||||
/tmp/parallel_results_test/testCstderr a II b IIII
|
||||
/tmp/parallel_results_test/testCstdout a I b III
|
||||
/tmp/parallel_results_test/testCstdout a I b IIII
|
||||
/tmp/parallel_results_test/testCstdout a II b III
|
||||
/tmp/parallel_results_test/testCstdout a II b IIII
|
||||
/tmp/parallel_results_test/testC/a/I/b/III/stderr
|
||||
/tmp/parallel_results_test/testC/a/I/b/III/stdout
|
||||
/tmp/parallel_results_test/testC/a/I/b/IIII/stderr
|
||||
/tmp/parallel_results_test/testC/a/I/b/IIII/stdout
|
||||
/tmp/parallel_results_test/testC/a/II/b/III/stderr
|
||||
/tmp/parallel_results_test/testC/a/II/b/III/stdout
|
||||
/tmp/parallel_results_test/testC/a/II/b/IIII/stderr
|
||||
/tmp/parallel_results_test/testC/a/II/b/IIII/stdout
|
||||
### Test --results --header : piped
|
||||
/tmp/parallel_results_test/testF_stderr Col backslash\\tab\tslash\_null\0eof
|
||||
/tmp/parallel_results_test/testF_stdout Col backslash\\tab\tslash\_null\0eof
|
||||
/tmp/parallel_results_test/testF/Col/backslash\\tab\tslash\_null\0eof/stderr
|
||||
/tmp/parallel_results_test/testF/Col/backslash\\tab\tslash\_null\0eof/stdout
|
||||
|
|
Loading…
Reference in a new issue